protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; if (s == "OK") { if (Request.QueryString["party"] != null && Request.QueryString["no"] != null) { string no = SafeValue.SafeString(Request.QueryString["no"]); string whCode = SafeValue.SafeString(Request.QueryString["wh"]); for (int a = 0; a < list.Count; a++) { string sql = ""; #region Do Out Det int id = list[a].id; int qty = list[a].qty; try { sql = string.Format("select * from Wh_DoDet where Id={0} ", id); ASPxSpinEdit spin_Qty1 = this.grid.FindRowTemplateControl(a, "spin_Qty1") as ASPxSpinEdit; ASPxSpinEdit spin_Qty2 = this.grid.FindRowTemplateControl(a, "spin_Qty2") as ASPxSpinEdit; int packQty = SafeValue.SafeInt(spin_Qty1.Text, 0); int locaQty = SafeValue.SafeInt(spin_Qty2.Text, 0); DataTable tab = ConnectSql.GetTab(sql); if (tab.Rows.Count == 1) { int i = 0; string product = tab.Rows[i]["ProductCode"].ToString(); string DoInNo = tab.Rows[i]["DoNo"].ToString(); decimal price = SafeValue.SafeDecimal(tab.Rows[i]["Price"], 0); string currency = SafeValue.SafeString(tab.Rows[i]["Currency"]); decimal exRate = SafeValue.SafeDecimal(tab.Rows[i]["ExRate"], 1); decimal gst = SafeValue.SafeDecimal(tab.Rows[i]["Gst"], 0); string gstType = SafeValue.SafeString(tab.Rows[i]["GstType"]); string batchNo = SafeValue.SafeString(tab.Rows[i]["BatchNo"]); DateTime expiredDate = SafeValue.SafeDate(tab.Rows[i]["ExpiredDate"], DateTime.Today); string color = SafeValue.SafeString(tab.Rows[i]["Color"]); decimal size = SafeValue.SafeDecimal(tab.Rows[i]["Size"], 0); string packCode = SafeValue.SafeString(tab.Rows[i]["PackCode"]); string unit = SafeValue.SafeString(tab.Rows[i]["Unit"]); int balQty = SafeValue.SafeInt(tab.Rows[i]["BalQty"], 0); WhDoDet det = new WhDoDet(); if (gstType == "S") { gst = SafeValue.SafeDecimal(0.07, 0); } det.ProductCode = product; det.Currency = currency; det.ExRate = exRate; det.Price = price; det.Qty1 = packQty; det.Qty2 = locaQty; det.Qty = packQty * locaQty; det.DoInNo = DoInNo; det.DoInId = id.ToString(); det.Gst = gst; det.GstType = gstType; det.BalQty = 0; det.PreQty = qty; det.DoNo = no; det.BatchNo = batchNo; det.ExpiredDate = expiredDate; det.Color = color; det.Size = size; det.DoType = "OUT"; det.JobStatus = "Draft"; det.PackCode = packCode; det.ContractNo = SafeValue.SafeString(tab.Rows[i]["ContractNo"]); det.DocAmt = SafeValue.SafeDecimal(tab.Rows[i]["DocAmt"], 0); det.GstAmt = SafeValue.SafeDecimal(tab.Rows[i]["GstAmt"], 0); det.DocAmt = SafeValue.SafeDecimal(tab.Rows[i]["DocAmt"], 0); det.LocAmt = SafeValue.SafeDecimal(tab.Rows[i]["LocAmt"], 0); if (balQty >= qty && packQty > 0 && locaQty > 0) { C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(det); UpdateBalQty(id, 0); } else { e.Result = "Error, Pls refresh your Det"; } } } catch (Exception ex) { } #endregion } } } }
public static string Import_Order(string filePath) { XmlDocument xmlDoc = new XmlDocument(); string doNo = ""; string doType = ""; if (filePath.Length > 0) { xmlDoc.Load(filePath); if (xmlDoc.SelectSingleNode("Order") != null) { XmlElement elem = (XmlElement)xmlDoc.SelectSingleNode("Order"); string id = SafeValue.SafeString(elem.GetAttribute("Id")); string relaId = SafeValue.SafeString(elem.GetAttribute("RelaId")); bool isNew = false; WhDo whDo = null; if (id.Length > 0 && relaId.Length == 0)// from company to warehouse { Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhDo), "RelaId='" + id + "'"); whDo = C2.Manager.ORManager.GetObject(query) as WhDo; if (whDo == null) { isNew = true; whDo = new WhDo(); whDo.RelaId = id; whDo.DoDate = DateTime.Today; whDo.PartyId = SafeValue.SafeString(elem.GetAttribute("PartyId")); //whDo.PartyId = EzshipHelper.GetPartyId(SafeValue.SafeString(elem.GetAttribute("PartyId"))); whDo.PartyName = SafeValue.SafeString(elem.GetAttribute("Party")); whDo.PartyAdd = SafeValue.SafeString(elem.GetAttribute("PartyAddress")); } } else if (id.Length > 0 && relaId.Length > 0)// from warehouse to company { Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhDo), "Id='" + relaId + "'"); whDo = C2.Manager.ORManager.GetObject(query) as WhDo; if (whDo == null) { return(""); //isNew = true; //whDo = new WhDo(); //whDo.RelatId = id; } } else { return(""); } doType = "IN"; string runType = "DOIN";//SIF/SIL/SIC if (SafeValue.SafeString(elem.GetAttribute("OrderType")) == "OUT") { doType = "OUT"; runType = "DOOUT"; } #region ref whDo.PoNo = SafeValue.SafeString(elem.GetAttribute("PoNo")); whDo.PoDate = SafeValue.SafeDate(elem.GetAttribute("PoDate"), DateTime.Today); //whDo.PartyId = EzshipHelper.GetPartyId(SafeValue.SafeString(elem.GetAttribute("Party"))); //whDo.PartyName = SafeValue.SafeString(elem.GetAttribute("Party")); //whDo.PartyAdd = SafeValue.SafeString(elem.GetAttribute("PartyAddress")); //whDo.PartyPostalcode = SafeValue.SafeString(elem.GetAttribute("PartyPostal")); //whDo.PartyCity = SafeValue.SafeString(elem.GetAttribute("PartyCity")); //whDo.PartyCountry = SafeValue.SafeString(elem.GetAttribute("PartyCountry")); whDo.Priority = SafeValue.SafeString(elem.GetAttribute("Type")); whDo.ExpectedDate = SafeValue.SafeDate(elem.GetAttribute("ExpectedDate"), DateTime.Today); whDo.DoStatus = SafeValue.SafeString(elem.GetAttribute("DoStatus")); whDo.Remark1 = SafeValue.SafeString(elem.GetAttribute("Remark1")); whDo.Remark2 = SafeValue.SafeString(elem.GetAttribute("Remark2")); whDo.CollectFrom = SafeValue.SafeString(elem.GetAttribute("PickFrom")); whDo.DeliveryTo = SafeValue.SafeString(elem.GetAttribute("DeliveryTo")); //whDo.CustomerReference = SafeValue.SafeString(elem.GetAttribute("CustomsRef")); //whDo.CustomerDate= SafeValue.SafeDate(elem.GetAttribute("RefDate"), new DateTime(1753, 1, 1)); whDo.CustomerReference = SafeValue.SafeString(elem.GetAttribute("OrderNo")); whDo.CustomerDate = SafeValue.SafeDate(elem.GetAttribute("OrderDate"), new DateTime(1753, 1, 1)); whDo.PartyInvNo = SafeValue.SafeString(elem.GetAttribute("PartyInvNo")); whDo.PartyInvDate = SafeValue.SafeDate(elem.GetAttribute("PartyInvDate"), new DateTime(1753, 5, 1)); //permit no whDo.PermitNo = SafeValue.SafeString(elem.GetAttribute("PermitNo")); whDo.PermitApprovalDate = SafeValue.SafeDate(elem.GetAttribute("PermitApprovalDate"), new DateTime(1753, 5, 1)); whDo.TptMode = SafeValue.SafeString(elem.GetAttribute("TptMode")); whDo.PalletizedInd = SafeValue.SafeBool(elem.GetAttribute("PalletizedInd"), true); whDo.EquipNo = SafeValue.SafeString(elem.GetAttribute("EquipNo")); whDo.Personnel = SafeValue.SafeString(elem.GetAttribute("Personnel")); //shipment whDo.Vessel = SafeValue.SafeString(elem.GetAttribute("Vessel")); whDo.Voyage = SafeValue.SafeString(elem.GetAttribute("Voyage")); whDo.Obl = SafeValue.SafeString(elem.GetAttribute("OceanBl")); whDo.Hbl = SafeValue.SafeString(elem.GetAttribute("HouseBl")); whDo.Pol = SafeValue.SafeString(elem.GetAttribute("Pol")); whDo.Pod = SafeValue.SafeString(elem.GetAttribute("Pod")); whDo.Eta = SafeValue.SafeDate(elem.GetAttribute("Eta"), new DateTime(1753, 1, 1)); whDo.Etd = SafeValue.SafeDate(elem.GetAttribute("Etd"), new DateTime(1753, 1, 1)); whDo.EtaDest = SafeValue.SafeDate(elem.GetAttribute("EtaDest"), new DateTime(1753, 1, 1)); whDo.Vehicle = SafeValue.SafeString(elem.GetAttribute("Vehicle")); whDo.Coo = SafeValue.SafeString(elem.GetAttribute("Coo")); whDo.Carrier = SafeValue.SafeString(elem.GetAttribute("Carrier")); //party whDo.AgentId = EzshipHelper.GetPartyId(SafeValue.SafeString(elem.GetAttribute("Agent"))); whDo.AgentName = SafeValue.SafeString(elem.GetAttribute("Agent")); whDo.AgentZip = SafeValue.SafeString(elem.GetAttribute("AgentZip")); whDo.AgentAdd = SafeValue.SafeString(elem.GetAttribute("AgentAddress")); whDo.AgentTel = SafeValue.SafeString(elem.GetAttribute("AgentTel")); whDo.AgentContact = SafeValue.SafeString(elem.GetAttribute("AgentContact")); whDo.AgentCountry = SafeValue.SafeString(elem.GetAttribute("AgentCountry")); whDo.AgentCity = SafeValue.SafeString(elem.GetAttribute("AgentCity")); whDo.NotifyId = EzshipHelper.GetPartyId(SafeValue.SafeString(elem.GetAttribute("Notify"))); whDo.NotifyName = SafeValue.SafeString(elem.GetAttribute("Notify")); whDo.NotifyZip = SafeValue.SafeString(elem.GetAttribute("NotifyZip")); whDo.NotifyAdd = SafeValue.SafeString(elem.GetAttribute("NotifyAddress")); whDo.NotifyTel = SafeValue.SafeString(elem.GetAttribute("NotifyTel")); whDo.NotifyContact = SafeValue.SafeString(elem.GetAttribute("NotifyContact")); whDo.NotifyCountry = SafeValue.SafeString(elem.GetAttribute("NotifyCountry")); whDo.NotifyCity = SafeValue.SafeString(elem.GetAttribute("NotifyCity")); whDo.ConsigneeId = EzshipHelper.GetPartyId(SafeValue.SafeString(elem.GetAttribute("Cnee"))); whDo.ConsigneeName = SafeValue.SafeString(elem.GetAttribute("Cnee")); whDo.ConsigneeZip = SafeValue.SafeString(elem.GetAttribute("CneeZip")); whDo.ConsigneeAdd = SafeValue.SafeString(elem.GetAttribute("CneeAddress")); whDo.ConsigneeTel = SafeValue.SafeString(elem.GetAttribute("CneeTel")); whDo.ConsigneeContact = SafeValue.SafeString(elem.GetAttribute("CneeContact")); whDo.ConsigneeCountry = SafeValue.SafeString(elem.GetAttribute("CneeCountry")); whDo.ConsigneeCity = SafeValue.SafeString(elem.GetAttribute("CneeCity")); whDo.PermitBy = SafeValue.SafeString(elem.GetAttribute("PermitBy")); whDo.OtherPermit = SafeValue.SafeString(elem.GetAttribute("OtherPermit")); whDo.ModelType = SafeValue.SafeString(elem.GetAttribute("ModelType")); if (isNew) { doNo = C2Setup.GetNextNo("", runType, DateTime.Today); whDo.DoNo = doNo; whDo.DoType = doType; whDo.StatusCode = "USE"; whDo.CreateBy = EzshipHelper.GetUserName(); whDo.CreateDateTime = DateTime.Today; Manager.ORManager.StartTracking(whDo, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(whDo); C2Setup.SetNextNo("", runType, doNo, whDo.DoDate); } else { doNo = whDo.DoNo; whDo.UpdateBy = EzshipHelper.GetUserName(); whDo.UpdateDateTime = DateTime.Now; Manager.ORManager.StartTracking(whDo, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(whDo); } #endregion #region Delete if (!isNew) { string sql_del = string.Format(@"delete from Wh_DoDet where DoNo='{0}'", doNo); SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_del), 0); sql_del = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}'", doNo); SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_del), 0); sql_del = string.Format(@"delete from Wh_DoDet3 where DoNo='{0}'", doNo); SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_del), 0); } #endregion #region sku XmlNodeList nodeListCont = elem.SelectNodes("Sku"); foreach (XmlNode xnMkg in nodeListCont) { XmlElement elemSku = (XmlElement)xnMkg; if (elemSku.Name == "Sku") { WhDoDet det = new WhDoDet(); det.DoNo = doNo; det.DoType = doType; det.LotNo = SafeValue.SafeString(elemSku.GetAttribute("LotNo")); det.BatchNo = SafeValue.SafeString(elemSku.GetAttribute("BatchNo")); det.CustomsLot = SafeValue.SafeString(elemSku.GetAttribute("CustomsLot")); det.ProductCode = SafeValue.SafeString(elemSku.GetAttribute("Sku")); det.Des1 = SafeValue.SafeString(elemSku.GetAttribute("Des")); det.Qty1 = SafeValue.SafeInt(elemSku.GetAttribute("PackQty"), 0); det.Qty2 = SafeValue.SafeInt(elemSku.GetAttribute("WholeQty"), 0); det.Qty3 = SafeValue.SafeInt(elemSku.GetAttribute("LooseQty"), 0); det.Qty4 = SafeValue.SafeInt(elemSku.GetAttribute("Expected"), 0); det.Qty5 = SafeValue.SafeInt(elemSku.GetAttribute("Transit"), 0); det.QtyPackWhole = SafeValue.SafeInt(elemSku.GetAttribute("QtyPackWhole"), 0); det.QtyWholeLoose = SafeValue.SafeInt(elemSku.GetAttribute("QtyWholeLoose"), 0); det.QtyLooseBase = SafeValue.SafeInt(elemSku.GetAttribute("QtyLooseBase"), 0); det.Uom1 = SafeValue.SafeString(elemSku.GetAttribute("PackUom")); det.Uom2 = SafeValue.SafeString(elemSku.GetAttribute("WholeUom")); det.Uom3 = SafeValue.SafeString(elemSku.GetAttribute("LooseUom")); det.Uom4 = SafeValue.SafeString(elemSku.GetAttribute("BaseUom")); det.Att1 = SafeValue.SafeString(elemSku.GetAttribute("Att1")); det.Att2 = SafeValue.SafeString(elemSku.GetAttribute("Att2")); det.Att3 = SafeValue.SafeString(elemSku.GetAttribute("Att3")); det.Att4 = SafeValue.SafeString(elemSku.GetAttribute("Att4")); det.Att5 = SafeValue.SafeString(elemSku.GetAttribute("Att5")); det.Att6 = SafeValue.SafeString(elemSku.GetAttribute("Att6")); det.Att7 = SafeValue.SafeString(elemSku.GetAttribute("Att7")); det.Att8 = SafeValue.SafeString(elemSku.GetAttribute("Att8")); det.Att9 = SafeValue.SafeString(elemSku.GetAttribute("Att9")); det.Att10 = SafeValue.SafeString(elemSku.GetAttribute("Att10")); det.CreateBy = EzshipHelper.GetUserName(); det.CreateDateTime = DateTime.Now; det.UpdateBy = EzshipHelper.GetUserName(); det.UpdateDateTime = DateTime.Now; Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(det); } } #endregion #region PutAway XmlNodeList nodeListCont1 = elem.SelectNodes("PutAway"); foreach (XmlNode xnMkg in nodeListCont1) { XmlElement elemPutAway = (XmlElement)xnMkg; if (elemPutAway.Name == "PutAway") { WhDoDet2 det = new WhDoDet2(); det.DoNo = doNo; det.DoType = doType; det.LotNo = SafeValue.SafeString(elemPutAway.GetAttribute("LotNo")); det.Product = SafeValue.SafeString(elemPutAway.GetAttribute("Product")); det.Des1 = SafeValue.SafeString(elemPutAway.GetAttribute("Des")); det.BatchNo = SafeValue.SafeString(elemPutAway.GetAttribute("BatchNo")); det.CustomsLot = SafeValue.SafeString(elemPutAway.GetAttribute("CustomsLot")); det.Location = SafeValue.SafeString(elemPutAway.GetAttribute("Location")); det.ProcessStatus = SafeValue.SafeString(elemPutAway.GetAttribute("ProcessStatus")); det.Qty1 = SafeValue.SafeInt(elemPutAway.GetAttribute("PackQty"), 0); det.Qty2 = SafeValue.SafeInt(elemPutAway.GetAttribute("WholeQty"), 0); det.Qty3 = SafeValue.SafeInt(elemPutAway.GetAttribute("LooseQty"), 0); det.QtyPackWhole = SafeValue.SafeInt(elemPutAway.GetAttribute("QtyPackWhole"), 0); det.QtyWholeLoose = SafeValue.SafeInt(elemPutAway.GetAttribute("QtyWholeLoose"), 0); det.QtyLooseBase = SafeValue.SafeInt(elemPutAway.GetAttribute("QtyLooseBase"), 0); det.Uom1 = SafeValue.SafeString(elemPutAway.GetAttribute("PackUom")); det.Uom2 = SafeValue.SafeString(elemPutAway.GetAttribute("WholeUom")); det.Uom3 = SafeValue.SafeString(elemPutAway.GetAttribute("LooseUom")); det.Uom4 = SafeValue.SafeString(elemPutAway.GetAttribute("BaseUom")); det.Att1 = SafeValue.SafeString(elemPutAway.GetAttribute("Att1")); det.Att2 = SafeValue.SafeString(elemPutAway.GetAttribute("Att2")); det.Att3 = SafeValue.SafeString(elemPutAway.GetAttribute("Att3")); det.Att4 = SafeValue.SafeString(elemPutAway.GetAttribute("Att4")); det.Att5 = SafeValue.SafeString(elemPutAway.GetAttribute("Att5")); det.Att6 = SafeValue.SafeString(elemPutAway.GetAttribute("Att6")); det.Att7 = SafeValue.SafeString(elemPutAway.GetAttribute("Att7")); det.Att8 = SafeValue.SafeString(elemPutAway.GetAttribute("Att8")); det.Att9 = SafeValue.SafeString(elemPutAway.GetAttribute("Att9")); det.Att10 = SafeValue.SafeString(elemPutAway.GetAttribute("Att10")); det.CreateBy = EzshipHelper.GetUserName(); det.CreateDateTime = DateTime.Now; det.UpdateBy = EzshipHelper.GetUserName(); det.UpdateDateTime = DateTime.Now; Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(det); } } #endregion #region Container XmlNodeList nodeListCont2 = elem.SelectNodes("Container"); foreach (XmlNode xnMkg in nodeListCont2) { XmlElement elemContainer = (XmlElement)xnMkg; if (elemContainer.Name == "Container") { WhDoDet3 det = new WhDoDet3(); det.DoNo = doNo; det.DoType = doType; det.ContainerNo = SafeValue.SafeString(elemContainer.GetAttribute("ContainerNo")); det.ContainerType = SafeValue.SafeString(elemContainer.GetAttribute("ContainerType")); det.SealNo = SafeValue.SafeString(elemContainer.GetAttribute("SealNo")); det.Weight = SafeValue.SafeDecimal(elemContainer.GetAttribute("Weight")); det.M3 = SafeValue.SafeDecimal(elemContainer.GetAttribute("M3")); det.Qty = SafeValue.SafeInt(elemContainer.GetAttribute("Qty"), 0); det.PkgType = SafeValue.SafeString(elemContainer.GetAttribute("PkgType")); det.CreateBy = EzshipHelper.GetUserName(); det.CreateDateTime = DateTime.Now; det.UpdateBy = EzshipHelper.GetUserName(); det.UpdateDateTime = DateTime.Now; Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(det); } } #endregion } } return("Type=" + doType + " , " + "No=" + doNo); }