/// <summary> /// 得到一个对象实体 /// </summary> public UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesShipment DataRowToModel(DataRow row) { UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesShipment model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesShipment(); if (row != null) { if (row["iID"] != null && row["iID"].ToString() != "") { model.iID = int.Parse(row["iID"].ToString()); } if (row["LotNO"] != null) { model.LotNO = row["LotNO"].ToString(); } if (row["cSOCode"] != null) { model.cSOCode = row["cSOCode"].ToString(); } if (row["SaleOrderRow"] != null && row["SaleOrderRow"].ToString() != "") { model.SaleOrderRow = int.Parse(row["SaleOrderRow"].ToString()); } if (row["iSOsID"] != null && row["iSOsID"].ToString() != "") { model.iSOsID = int.Parse(row["iSOsID"].ToString()); } if (row["ItemNO"] != null) { model.ItemNO = row["ItemNO"].ToString(); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } if (row["cCusCode"] != null) { model.cCusCode = row["cCusCode"].ToString(); } if (row["OrderQTY"] != null && row["OrderQTY"].ToString() != "") { model.OrderQTY = decimal.Parse(row["OrderQTY"].ToString()); } if (row["LOTQTY"] != null && row["LOTQTY"].ToString() != "") { model.LOTQTY = decimal.Parse(row["LOTQTY"].ToString()); } if (row["DEPT"] != null) { model.DEPT = row["DEPT"].ToString(); } if (row["Process"] != null) { model.Process = row["Process"].ToString(); } if (row["ProcessNext"] != null) { model.ProcessNext = row["ProcessNext"].ToString(); } if (row["OtherQTY"] != null && row["OtherQTY"].ToString() != "") { model.OtherQTY = decimal.Parse(row["OtherQTY"].ToString()); } if (row["Status"] != null) { model.Status = row["Status"].ToString(); } if (row["cSTCode"] != null) { model.cSTCode = row["cSTCode"].ToString(); } if (row["CurrQTY"] != null && row["CurrQTY"].ToString() != "") { model.CurrQTY = decimal.Parse(row["CurrQTY"].ToString()); } if (row["CreateUid"] != null) { model.CreateUid = row["CreateUid"].ToString(); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesShipment model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.LotNO != null) { strSql1.Append("LotNO,"); strSql2.Append("'" + model.LotNO + "',"); } if (model.cSOCode != null) { strSql1.Append("cSOCode,"); strSql2.Append("'" + model.cSOCode + "',"); } if (model.CartonNo != null) { strSql1.Append("CartonNo,"); strSql2.Append("'" + model.CartonNo + "',"); } if (model.SaleOrderRow != null) { strSql1.Append("SaleOrderRow,"); strSql2.Append("" + model.SaleOrderRow + ","); } if (model.iSOsID != null) { strSql1.Append("iSOsID,"); strSql2.Append("" + model.iSOsID + ","); } if (model.ItemNO != null) { strSql1.Append("ItemNO,"); strSql2.Append("'" + model.ItemNO + "',"); } if (model.Description != null) { strSql1.Append("Description,"); strSql2.Append("'" + model.Description + "',"); } if (model.cCusCode != null) { strSql1.Append("cCusCode,"); strSql2.Append("'" + model.cCusCode + "',"); } if (model.OrderQTY != null) { strSql1.Append("OrderQTY,"); strSql2.Append("" + model.OrderQTY + ","); } if (model.LOTQTY != null) { strSql1.Append("LOTQTY,"); strSql2.Append("" + model.LOTQTY + ","); } if (model.DEPT != null) { strSql1.Append("DEPT,"); strSql2.Append("'" + model.DEPT + "',"); } if (model.Process != null) { strSql1.Append("Process,"); strSql2.Append("'" + model.Process + "',"); } if (model.ProcessNext != null) { strSql1.Append("ProcessNext,"); strSql2.Append("'" + model.ProcessNext + "',"); } if (model.OtherQTY != null) { strSql1.Append("OtherQTY,"); strSql2.Append("" + model.OtherQTY + ","); } if (model.Status != null) { strSql1.Append("Status,"); strSql2.Append("'" + model.Status + "',"); } if (model.cSTCode != null) { strSql1.Append("cSTCode,"); strSql2.Append("'" + model.cSTCode + "',"); } if (model.CurrQTY != null) { strSql1.Append("CurrQTY,"); strSql2.Append("" + model.CurrQTY + ","); } if (model.CreateUid != null) { strSql1.Append("CreateUid,"); strSql2.Append("'" + model.CreateUid + "',"); } if (model.CreateDate != null) { strSql1.Append("CreateDate,"); strSql2.Append("'" + model.CreateDate + "',"); } strSql.Append("insert into _SalesShipment("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); return(strSql.ToString()); }
private void btnSave_Click(object sender, EventArgs e) { try { gridView1.FocusedRowHandle -= 1; gridView1.FocusedRowHandle += 1; } catch { } txtBarCode.Focus(); string sErr = ""; int iCount = 0; try { if (gridView1.RowCount < 1) { throw new Exception("Please scan barcode"); } string sProcess = gridView1.GetRowCellValue(0, gridColProcess).ToString().Trim(); SqlConnection conn = new SqlConnection(Conn); conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { string sSQL = "select getdate()"; DateTime dNow = BaseFunction.ReturnDate(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]); DateTime dNowDate = BaseFunction.ReturnDate(dNow.ToString("yyyy-MM-dd")); for (int i = 0; i < gridView1.RowCount; i++) { long lSOsID = BaseFunction.ReturnLong(gridView1.GetRowCellValue(i, gridColiSOsID)); sSQL = @" select * from SO_SOMain a inner join SO_SODetails b on a.ID = b.ID left join _SystemSet c on a.cSTCode = c.cSTCode inner join Inventory d on b.cInvCode = d.cInvCode inner join [_BarCodeLabel] e on e.[iSOsID] = b.[iSOsID] where b.iSOsID = aaaaaa order by b.autoid "; sSQL = sSQL.Replace("aaaaaa", lSOsID.ToString().Trim()); DataTable dtSODetails = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0]; if (dtSODetails == null || dtSODetails.Rows.Count == 0) { throw new Exception("Sale Order not exists err"); } //if (gridView1.GetRowCellValue(i, gridColcCusCode).ToString().Trim() != sCusCode) //{ // sErr = sErr + "Row " + (i + 1).ToString() + " customer err\n"; // continue; //} string sBarCode = gridView1.GetRowCellValue(i, gridColLotNO).ToString().Trim(); Model._SalesShipment model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesShipment(); model.cCusCode = gridView1.GetRowCellValue(i, gridColcCusCode).ToString().Trim(); model.CreateDate = dNow; model.CreateUid = sUserID; model.cSOCode = gridView1.GetRowCellValue(i, gridColcSOCode).ToString(); model.cSTCode = gridView1.GetRowCellValue(i, gridColcSTCode).ToString(); model.CurrQTY = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColCurrQTY)); //model.DEPT model.Description = gridView1.GetRowCellValue(i, gridColDescription).ToString(); model.iSOsID = BaseFunction.ReturnLong(gridView1.GetRowCellValue(i, gridColiSOsID)); model.ItemNO = gridView1.GetRowCellValue(i, gridColItemNO).ToString(); model.LotNO = sBarCode; model.LOTQTY = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColLOTQTY)); model.OrderQTY = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColOrderQTY)); model.OtherQTY = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColOtherQTY)); model.Process = gridView1.GetRowCellValue(i, gridColProcess).ToString(); //model.ProcessNext = gridView1.GetRowCellValue(i,gridCol model.SaleOrderRow = BaseFunction.ReturnLong(gridView1.GetRowCellValue(i, gridColSaleOrderRow)); //model.Status = "ship" model.CartonNo = gridView1.GetRowCellValue(i, gridColCartonNo).ToString().Trim(); DAL._SalesShipment dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._SalesShipment(); sSQL = dal.Add(model); iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); sSQL = "update _BarCodeLabel set [Status] = 'Pending' where BarCode = 'aaaaaa' and iSOsID = bbbbbb"; sSQL = sSQL.Replace("aaaaaa", gridView1.GetRowCellValue(i, gridColLotNO).ToString().Trim()); sSQL = sSQL.Replace("bbbbbb", model.iSOsID.ToString()); DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); Model.BarStatus modBarStatus = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.BarStatus(); modBarStatus.BarCode = gridView1.GetRowCellValue(i, gridColLotNO).ToString().Trim(); modBarStatus.iSOsID = lSOsID; modBarStatus.Type = "Pending"; modBarStatus.UpdateTime = dNow; modBarStatus.QTY = model.LOTQTY; modBarStatus.CreateUid = sUserID; modBarStatus.CreateDate = dNow; modBarStatus.RoutingFrom = lookUpEditProcess.EditValue.ToString().Trim(); modBarStatus.RoutingTo = lookUpEditProcess.EditValue.ToString().Trim(); DAL.BarStatus dalBarStatus = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.BarStatus(); sSQL = dalBarStatus.Add(modBarStatus); DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL); } if (sErr.Trim() != "") { throw new Exception(sErr); } if (iCount > 0) { tran.Commit(); SetTxtNull(); gridControl1.DataSource = DbHelperSQL.Query(sSQLBar); txtBarCode.Focus(); } } catch (Exception ee) { tran.Rollback(); throw new Exception(ee.Message); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }