public static int SaveAPAdjustDet(APAdjustDet info) { int kq = ConnectDB.ExecuteScalar("sp_APAdjustDetSave", new String[] { "BranchID","AdjNbr","LineRef","VendID","AdjDate","AdjAcct" ,"AdjAmt","NDocNbr","NDocType","NDocDate","ADocNbr","ADocType" ,"ADocDate","Rlsed","Crtd_DateTime","Crtd_Prog","Crtd_User" ,"LUpd_DateTime","LUpd_Prog","LUpd_User","Version" }, new Object[] { info.BranchID,info.AdjNbr,info.LineRef,info.VendID,info.AdjDate,info.AdjAcct ,info.AdjAmt,info.NDocNbr,info.NDocType,info.NDocDate,info.ADocNbr,info.ADocType ,info.ADocDate,info.Rlsed,info.Crtd_DateTime,info.Crtd_Prog,info.Crtd_User ,info.LUpd_DateTime,info.LUpd_Prog,info.LUpd_User,info.Version }); return kq; }
private int _SaveAPAdjustDet() { string strBrandID = cmbBranchID.SelectedValue.ToString().Trim(); string strAdjNbr = txtAdjNbr.Text.ToString().Trim(); //string strAdjNbr = "tmp"; DateTime dteAdjDate = dtmAdjDate.Value.Date; string strAdjAcct = ""; double dbeAdjAmt = double.Parse(txtAdjAmt.Text.ToString().Trim()); //DataTable list = new DataTable(); //list = AP202Ctrl.FindAPADjustDet(""); if (dgvADocList.DataSource == _dtADoc) { DataTable t1 = new DataTable(); string sql1 = string.Format("Payment > 0 "); t1 = _dtADoc.Copy(); t1.DefaultView.RowFilter = sql1; t1.DefaultView.Sort = "Payment DESC"; t1 = t1.DefaultView.ToTable(); DataTable t2 = new DataTable(); string sql2 = string.Format("Payment > 0 "); t2 = _dtNDoc.Copy(); t2.DefaultView.RowFilter = sql2; t2.DefaultView.Sort = "Payment DESC"; t2 = t2.DefaultView.ToTable(); foreach (DataRow rows in t1.Rows) { foreach (DataRow rows2 in t2.Rows) { double s1 = double.Parse(rows["Payment"].ToString().Trim()); double s2 = double.Parse(rows2["Payment"].ToString().Trim()); if (s1 > 0 && s2 > 0) { if (s1 > s2 && s2 > 0) { APAdjustDet info = new APAdjustDet(); info.BranchID = strBrandID; info.AdjNbr = strAdjNbr; info.LineRef = "none"; info.VendID = rows["VendID"].ToString().Trim(); info.AdjDate = dteAdjDate; info.AdjAcct = strAdjAcct; info.AdjAmt = s2; info.ADocNbr = rows["DocNbr"].ToString().Trim(); info.ADocType = rows["DocType"].ToString().Trim(); info.ADocDate = DateTime.Parse(rows["DocDate"].ToString().Trim()).Date; info.NDocNbr = rows2["DocNbr"].ToString().Trim(); info.NDocType = rows2["DocType"].ToString().Trim(); info.NDocDate = DateTime.Parse(rows2["DocDate"].ToString().Trim()).Date; info.Rlsed = 0; info.Crtd_DateTime = DateTime.Now; info.Crtd_Prog = _strPro; info.Crtd_User = _strUser; info.LUpd_DateTime = DateTime.Now; info.LUpd_Prog = _strPro; info.LUpd_User = _strUser; info.Version = ""; AP203Ctrl.SaveAPAdjustDet(info); rows["Payment"] = s1 - s2; rows2["Payment"] = 0; } else if (s1 > 0) { APAdjustDet info = new APAdjustDet(); info.BranchID = strBrandID; info.AdjNbr = strAdjNbr; info.LineRef = "none"; info.VendID = rows["VendID"].ToString().Trim(); info.AdjDate = dteAdjDate; info.AdjAcct = strAdjAcct; info.AdjAmt = s1; info.ADocNbr = rows["DocNbr"].ToString().Trim(); info.ADocType = rows["DocType"].ToString().Trim(); info.ADocDate = DateTime.Parse(rows["DocDate"].ToString().Trim()).Date; info.NDocNbr = rows2["DocNbr"].ToString().Trim(); info.NDocType = rows2["DocType"].ToString().Trim(); info.NDocDate = DateTime.Parse(rows2["DocDate"].ToString().Trim()).Date; info.Rlsed = 0; info.Crtd_DateTime = DateTime.Now; info.Crtd_Prog = _strPro; info.Crtd_User = _strUser; info.LUpd_DateTime = DateTime.Now; info.LUpd_Prog = _strPro; info.LUpd_User = _strUser; info.Version = ""; AP203Ctrl.SaveAPAdjustDet(info); rows["Payment"] = 0; rows2["Payment"] = s2 - s1; } } } } } //else if (dgvDocList.DataSource == _dtAPAdjustDet) //{ // foreach (DataRow rows in _dtAPAdjustDet.Rows) // { // APAdjustDet info = new APAdjustDet(); // info.BranchID = strBrandID; // info.AdjNbr = strAdjAcct; // info.LineRef = rows["LineRef"].ToString().Trim();// intLineRef.ToString("00000"); // info.VendID = rows["VendID"].ToString().Trim(); // info.AdjDate = dteAdjDate; // info.AdjAcct = strAdjAcct; // info.AdjAmt = dbeAdjAmt; // info.NDocNbr = rows["NDocNbr"].ToString().Trim(); // info.NDocType = rows["NDocType"].ToString().Trim(); // info.NDocDate = DateTime.Parse(rows["NDocDate"].ToString().Trim()).Date; // info.ADocNbr = ""; // info.ADocType = ""; // //info.ADocDate = null; // info.Rlsed = 0; // info.Crtd_DateTime = DateTime.Now; // info.Crtd_Prog = _strPro; // info.Crtd_User = _strUser; // info.LUpd_DateTime = DateTime.Now; // info.LUpd_Prog = _strPro; // info.LUpd_User = _strUser; // info.Version = ""; // AP202Ctrl.SaveAPAdjust(_infoAPAdjust); // } //} return 1; }