private Model.SourceList GetSourceList(DataRow dr) { if (dr == null) { return(null); } Model.SourceList sl = new Model.SourceList(); sl.SourceListOID = Convert.ToInt32(dr["SourceListOID"]); sl.PartNumber = Convert.ToString(dr["PartNumber"]); sl.Batch = Convert.ToInt32(dr["Batch"]); sl.Discount = Convert.ToDecimal(dr["Discount"]); if (!SqlHelper.IsNull(dr["DiscountBeginDate"])) { sl.DiscountBeginDate = Convert.ToDateTime(dr["DiscountBeginDate"]); } if (!SqlHelper.IsNull(dr["DiscountEndDate"])) { sl.DiscountEndDate = Convert.ToDateTime(dr["DiscountEndDate"]); } if (!SqlHelper.IsNull(dr["CreateDate"])) { sl.CreateDate = Convert.ToDateTime(dr["CreateDate"]); } return(sl); }
private void btnAddToPO_Click(object sender, EventArgs e) { int qty = 0; if (!int.TryParse(txtQty.Text.Trim(), out qty)) { MessageBox.Show("請輸入正確數字"); return; } switch (this.CmdMode) { case CommandMode.Add: PurchasingOrderDetail pod = new PurchasingOrderDetail() { SourceListOID = Convert.ToInt32(this.cbSourceList.SelectedValue), Qty = qty }; PurchasingOrderUtil.SetPurchasingOrderDetail(pod); this.lblPODCount.Text = PurchasingOrderUtil.GetPurchasingOrderDetailStatus(); break; case CommandMode.Edit: PurchasingOrderDetail updatePod = PurchasingOrderUtil.GetPurchasingOrderDetail()[this.ListIndex]; updatePod.SourceListOID = Convert.ToInt32(this.cbSourceList.SelectedValue); updatePod.Qty = qty; Common.ContainerForm.NextForm(new POAddMainForm()); break; case CommandMode.OrderEdit: Model.SourceList sl = this.sourceLists.Find(s => s.SourceListOID.Equals(Convert.ToInt32(this.cbSourceList.SelectedValue))); this.SourceOrderListData.Batch = sl.Batch; this.SourceOrderListData.Discount = sl.Discount; this.SourceOrderListData.Qty = Convert.ToInt32(this.txtQty.Text); SourceOrderListDao dao = new SourceOrderListDao(); dao.Update(this.SourceOrderListData); CheckOrderForm cof = new CheckOrderForm(this.SourceOrderListData.GetOrderPart().OrderID, "edit"); Common.ContainerForm.NextForm(cof); break; default: break; } }
public Model.SourceList FindSourceListBySourceListOID(int SourceListOID) { string strCmd = @"SELECT SourceListOID, PartNumber, Batch, Discount, DiscountBeginDate, DiscountEndDate, CreateDate FROM SourceList where SourceListOID = @SourceListOID"; List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(SqlHelper.CreateParameter("@SourceListOID", SqlDbType.Int, SourceListOID)); DataTable dt = SqlHelper.AdapterFill(strCmd, parameters); if (dt.Rows.Count == 0) { return(null); } Model.SourceList sl = this.GetSourceList(dt.Rows[0]); return(sl); }