You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
220 lines
8.3 KiB
220 lines
8.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using System.Data;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSPJXPrintDal
|
|
{
|
|
public static void AddAndEdit(ICSPJXPrint Print, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
string Sup = "";
|
|
string date= DateTime.Now.DayOfYear.ToString().PadLeft(3,'0');
|
|
string sql = @"SELECT SUBSTRING(MAX(Supplier),len(Supplier)-6,3) AS Supplier,
|
|
SUBSTRING(MAX(Supplier),len(Supplier)-3,4) AS Supp,Mtime FROM ICSPJXPrint
|
|
WHERE Supplier LIKE '{0}%' GROUP BY Supplier,Mtime ORDER BY Mtime DESC";
|
|
sql = string.Format(sql, "75615B" + date);//取已存的transNo后三位
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt!=null && dt.Rows.Count>0)
|
|
{
|
|
Sup = "75615B" + dt.Rows[0][0].ToString() +( Convert.ToInt32(dt.Rows[0][1].ToString())+1).ToString().PadLeft(4,'0');
|
|
}
|
|
else
|
|
{
|
|
Sup = "75615B" + date + "0001";
|
|
}
|
|
var line = db.ICSPJXPrint.SingleOrDefault(a => a.DispatchListID == Print.DispatchListID && a.Free1==Print.Free1);
|
|
if(line==null){
|
|
isNew = true;
|
|
line = new ICSPJXPrint();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.ShipAddress = "No.210 East Qingdao Road,Taicang,Jiangsu, China.";
|
|
line.Level = "1A";
|
|
line.quantity = Print.quantity;
|
|
line.Supplier = Sup;
|
|
line.Component = Print.Component;
|
|
line.DispatchListID = Print.DispatchListID;
|
|
line.Free1 = Print.Free1;
|
|
}
|
|
line.quantity = Print.quantity;
|
|
line.MuserCode = AppConfig.UserCode;
|
|
line.MuserName = AppConfig.UserName;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.Mtime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
|
|
if (isNew) db.ICSPJXPrint.InsertOnSubmit(line);
|
|
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static ICSPJXPrint select(String guid, String Batch,String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSPJXPrint entity = new ICSPJXPrint();
|
|
try
|
|
{
|
|
var line = db.ICSPJXPrint.SingleOrDefault(a => a.DispatchListID == guid && a.Free1==Batch);
|
|
return (ICSPJXPrint)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static ICSPJXPrint selectByID(String guid, String con)
|
|
{
|
|
FramDataContext db = new FramDataContext(con);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSPJXPrint entity = new ICSPJXPrint();
|
|
try
|
|
{
|
|
var line = db.ICSPJXPrint.SingleOrDefault(a => a.DispatchListID == guid);
|
|
return (ICSPJXPrint)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static ICSPJXPrint selectByCode(String storagecode, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSPJXPrint.SingleOrDefault(a => a.DispatchListID == storagecode);
|
|
//entity.Serial = line.Serial;
|
|
//entity.StorageCode = line.StorageCode;
|
|
//entity.StorageName = line.StorageName;
|
|
//entity.MUSER = line.MUSER;
|
|
//entity.MTIME = line.MTIME;
|
|
//entity.EATTRIBUTE1 = line.EATTRIBUTE1;
|
|
|
|
return (ICSPJXPrint)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static void delete(List<String> guidList) {
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
var lines = db.ICSPJXPrint.Where(a => guidList.Contains(a.DispatchListID) && guidList.Contains(a.Free1));
|
|
db.ICSPJXPrint.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static void SaveInfo(DataTable data, string Appconstr) {
|
|
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
var StorageCode=data.Rows[i]["库房编号"].ToString();
|
|
var StorageName=data.Rows[i]["库房名称"].ToString();
|
|
ICSPJXPrint code = new ICSPJXPrint();
|
|
code.ID = AppConfig.GetGuid();
|
|
code.DispatchListID = StorageCode;
|
|
code.MuserCode = AppConfig.UserId;
|
|
code.MuserName = AppConfig.UserName;
|
|
code.WorkPoint = AppConfig.WorkPointCode;
|
|
code.Mtime = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString());
|
|
db.ICSPJXPrint.InsertOnSubmit(code);
|
|
}
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
}
|
|
|
|
public static void SaveConnect(string Connecting,string StorageSerial1,Dictionary<string ,string> ConnList)
|
|
{
|
|
FramDataContext db = new FramDataContext(Connecting);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
List<string> SerialList = new List<string>();
|
|
bool isNew = false;
|
|
//foreach (string Serial in ConnList.Keys)
|
|
//{
|
|
// //var line = db.ICSStorage2Storage.SingleOrDefault(a => a.Serial == Serial);
|
|
// //if (line == null)
|
|
// //{
|
|
// // isNew = true;
|
|
// // line = new ICSStorage2Storage();
|
|
// // line.Serial = Serial;
|
|
// //}
|
|
// line.Storage1Serial = StorageSerial1;
|
|
// line.Storage2Serial = ConnList[Serial];
|
|
// line.MTIME = DateTime.Now;
|
|
// line.MUSER = AppConfig.UserId;
|
|
// line.MUSERName = AppConfig.UserName;
|
|
// SerialList.Add(Serial);
|
|
// if (isNew) db.ICSStorage2Storage.InsertOnSubmit(line);
|
|
//}
|
|
|
|
//var lines = db.ICSStorage2Storage.Where(a => a.Storage1Serial == StorageSerial1 && !SerialList.Contains(a.Serial));
|
|
//db.ICSStorage2Storage.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|