protected void btnSave_Click(object sender, ImageClickEventArgs e) { try { ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); for (int Row = 0; Row < gvItemContent.Rows.Count; Row++) { CheckBox chkChoose = gvItemContent.Rows[Row].FindControl("chkChoose") as CheckBox; if (chkChoose.Checked) { decimal Qty = decimal.Parse(gvItemContent.Rows[Row].Cells[8].Text); long ItemMoveId = long.Parse(gvItemContent.DataKeys[Row][0].ToString()); long ProductionDetailsOrderId = long.Parse(gvItemContent.DataKeys[Row][1].ToString()); hfProductionDetailsOrderId.Value = ProductionDetailsOrderId.ToString(); ADAM.DataBase.ItemMovement itmMovementdr = mdb.ItemMovements.Single(a => a.Id == ItemMoveId); itmMovementdr.MainQtyOut = itmMovementdr.MainQtyOut + Qty; var Rows = from a in mdb.ItemMovements where a.MovmentnameId == 21 && a.ItemColorId == itmMovementdr.ItemColorId && a.ItemId == itmMovementdr.ItemId && a.DocmentId == ProductionDetailsOrderId select a; if (Rows.Count() > 0) { continue; } ADAM.DataBase.ItemMovement Nmovedr = new DataBase.ItemMovement(); Nmovedr.AdditionalQty = 0; Nmovedr.AdditionalQtyOut = 0; Nmovedr.AuditDetailsId = 0; Nmovedr.DocmentId = ProductionDetailsOrderId; Nmovedr.IncommingOrderNo = itmMovementdr.IncommingOrderNo; Nmovedr.ItemColorId = itmMovementdr.ItemColorId; Nmovedr.ItemId = itmMovementdr.ItemId; Nmovedr.ItemUnitId = itmMovementdr.ItemUnitId; Nmovedr.LocatioId = itmMovementdr.LocatioId; Nmovedr.MainQty = Qty * -1; Nmovedr.MainQtyOut = 0; Nmovedr.MovementDate = DateTime.Now; Nmovedr.MovmentnameId = 21; Nmovedr.RecDate = DateTime.Now; Nmovedr.StoreId = itmMovementdr.StoreId; Nmovedr.SupplyOrderDetailsId = 0; Nmovedr.ParentItemMoveMentId = itmMovementdr.Id; mdb.ItemMovements.Add(Nmovedr); mdb.SaveChanges(); } } ADAM.DataBase.ProductionDetailsOrder Proddr = mdb.ProductionDetailsOrders.Single(a => a.Id == long.Parse(hfProductionDetailsOrderId.Value)); Proddr.Status = 1; mdb.SaveChanges(); } catch { } }
protected void gvItems_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex != -1) { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.ItemMovement dr = Mdb.ItemMovements.Single(a => a.Id == long.Parse(gvItems.DataKeys[e.Row.RowIndex].Value.ToString())); TextBox txtMainQty = e.Row.FindControl("txtMainQty") as TextBox; txtMainQty.Text = dr.MainQty.ToString(); TextBox txtAdditionalQty = e.Row.FindControl("txtAdditionalQty") as TextBox; txtAdditionalQty.Text = dr.AdditionalQty.ToString(); DropDownList ddlLocation = e.Row.FindControl("ddlLocation") as DropDownList; ddlLocation.SelectedValue = dr.LocatioId.ToString(); DropDownList ddlItemColor = e.Row.FindControl("ddlItemColor") as DropDownList; ddlItemColor.SelectedValue = dr.ItemColorId.ToString(); } }
protected void gvItems_SelectedIndexChanged(object sender, EventArgs e) { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.ItemMovement dr = Mdb.ItemMovements.Single(a => a.Id == long.Parse(gvItems.SelectedDataKey.Value.ToString())); TextBox txtMainQty = gvItems.SelectedRow.FindControl("txtMainQty") as TextBox; TextBox txtAdditionalQty = gvItems.SelectedRow.FindControl("txtAdditionalQty") as TextBox; DropDownList ddlLocation = gvItems.SelectedRow.FindControl("ddlLocation") as DropDownList; DropDownList ddlItemColor = gvItems.SelectedRow.FindControl("ddlItemColor") as DropDownList; dr.MainQty = decimal.Parse(txtMainQty.Text); dr.AdditionalQty = decimal.Parse(txtAdditionalQty.Text); dr.LocatioId = long.Parse(ddlLocation.SelectedValue); dr.ItemColorId = int.Parse(ddlItemColor.SelectedValue); Mdb.SaveChanges(); }
protected void btnUpdate_Click(object sender, ImageClickEventArgs e) { try { ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); for (int Row = 0; Row < gvRecordReceiptData.Rows.Count; Row++) { CheckBox chkChoose = gvRecordReceiptData.Rows[Row].FindControl("chkChoose") as CheckBox; if (chkChoose.Checked) { TextBox txtQtyRec = gvRecordReceiptData.Rows[Row].FindControl("txtQtyRec") as TextBox; TextBox txtFreeQty = gvRecordReceiptData.Rows[Row].FindControl("txtFreeQty") as TextBox; long RecordReceiptDetailsId = long.Parse(gvRecordReceiptData.DataKeys[Row].Value.ToString()); ADAM.DataBase.RecordReceiptDetail dr = mdb.RecordReceiptDetails.Single(a => a.Id == RecordReceiptDetailsId); ADAM.DataBase.AuditDetail auddr = mdb.AuditDetails.Single(a => a.RecordReceiptDetailsId == dr.Id); if (auddr.AcceptQty > 0 || auddr.RefusedQty > 0) { Response.Write("<script>alert('لا يمكن التعديل لانه قد تم الفحص')</script>"); gvRecordReceiptData.Rows[Row].BackColor = System.Drawing.Color.Red; return; } dr.QtyReceived = decimal.Parse(txtQtyRec.Text); dr.FreeQty = decimal.Parse(txtFreeQty.Text); ADAM.DataBase.ItemMovement movdr = mdb.ItemMovements.Single(a => a.DocmentId == dr.Id); movdr.MainQty = dr.QtyReceived; movdr.AdditionalQty = dr.FreeQty; mdb.SaveChanges(); } } } catch { } }
protected void gvItemMovement_SelectedIndexChanged(object sender, EventArgs e) { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.ItemMovement movdr = Mdb.ItemMovements.Single(a => a.Id == long.Parse(gvItemMovement.SelectedDataKey.Value.ToString())); TextBox txtQtyOut = gvItemMovement.SelectedRow.FindControl("txtQtyOut") as TextBox; TextBox txtfreeQtyOut = gvItemMovement.SelectedRow.FindControl("txtfreeQtyOut") as TextBox; if ((movdr.MainQtyOut + decimal.Parse(txtQtyOut.Text) <= movdr.MainQty) && (movdr.AdditionalQtyOut + decimal.Parse(txtfreeQtyOut.Text) <= movdr.AdditionalQty)) { movdr.MainQtyOut = movdr.MainQtyOut + decimal.Parse(txtQtyOut.Text); movdr.AdditionalQtyOut = movdr.AdditionalQtyOut + decimal.Parse(txtfreeQtyOut.Text); var ExchangeRequestOrderRows = from a in Mdb.ExchangeRequestDetailsDatas where a.ExchangeRequestHeaderData.OrderType == long.Parse(ddlExchangeRequestType.SelectedValue) && a.Status == 1 orderby a.ExchangeRequestOrder descending select a; if (ExchangeRequestOrderRows.Count() <= 0) { hfExchangeRequestOrder.Value = "1"; } else { if (hfExchangeRequestOrder.Value == "0") { hfExchangeRequestOrder.Value = (ExchangeRequestOrderRows.First().ExchangeRequestOrder + 1).ToString(); } } ADAM.DataBase.ExchangeRequestDetailsData Exdr = Mdb.ExchangeRequestDetailsDatas.Single(a => a.Id == long.Parse(hfDetailsId.Value)); if ((decimal.Parse(txtQtyOut.Text)) > (Exdr.Qty + Exdr.Bounce)) { Response.Write("<script>alert('لا يمكن ان يكون الكمية المنصرفة اكبر من كمية طلب الصرف')</script>"); return; } if ((decimal.Parse(txtfreeQtyOut.Text)) > (Exdr.FreeQty)) { Response.Write("<script>alert('لا يمكن ان يكون الكمية Tester المنصرفة اكبر من كمية طلب الصرف')</script>"); return; } Exdr.ExchangeRequestOrder = long.Parse(hfExchangeRequestOrder.Value); Exdr.Status = 1; if (movdr.IncommingOrderNo != 0) { ADAM.DataBase.IncommingOrderData incdr = Mdb.IncommingOrderDatas.Single(a => a.IncommingOrderNo == movdr.IncommingOrderNo && a.AuditDetailsId == movdr.AuditDetailsId); Exdr.IncommingOrderId = incdr.Id; Exdr.LocationId = movdr.LocatioId; } ADAM.DataBase.ItemMovement dr = new DataBase.ItemMovement(); dr.AdditionalQty = decimal.Parse(txtfreeQtyOut.Text) * -1; dr.AdditionalQtyOut = 0; dr.AuditDetailsId = movdr.AuditDetailsId; dr.DocmentId = Exdr.Id; dr.IncommingOrderNo = movdr.IncommingOrderNo; dr.ItemColorId = movdr.ItemColorId; dr.ItemId = movdr.ItemId; dr.ItemUnitId = movdr.ItemUnitId; dr.LocatioId = movdr.LocatioId; dr.MainQty = decimal.Parse(txtQtyOut.Text) * -1; dr.MainQtyOut = 0; dr.MovementDate = DateTime.Now; dr.MovmentnameId = int.Parse(ddlExchangeRequestType.Text); dr.RecDate = DateTime.Now; dr.StoreId = movdr.StoreId; dr.SupplyOrderDetailsId = movdr.SupplyOrderDetailsId; dr.ParentItemMoveMentId = movdr.Id; Mdb.ItemMovements.Add(dr); Exdr.IncommingOrderNo = movdr.IncommingOrderNo; Mdb.SaveChanges(); Exdr.MovementId = dr.Id; gvExchangeRequestData.DataBind(); } else { Response.Write("<script>alert('لا يمكن ان يكون الكمية المنصرفة اكبر من كمية الرصيد الحالي')</script>"); return; } }
//protected void btnEditOrderItem_Click(object sender, ImageClickEventArgs e) //{ // try // { // ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); // ADAM.DataBase.RefluxDetailsData ddr = mdb.RefluxDetailsDatas.Single(a => a.Id == long.Parse(RefluxDetailsId.Value)); // if (ddr.RefluxHeaderData.OrderType == 1) // { // ADAM.DataBase.PurchaseOredrDetail purchasedr = mdb.PurchaseOredrDetails.Single(a => a.Id == ddr.ExchangeOrPurchaseDetailsId); // if (decimal.Parse(txtQty.Text) > purchasedr.ConformQty) // { // Response.Write("<script>alert('لا يمكن ان تكون الكمية المرتجعة اكبر من الكمية الموجوده في طلب الشراء')</script>"); // return; // } // } // if (ddr.RefluxHeaderData.OrderType == 2) // { // ADAM.DataBase.ExchangeRequestDetailsData detailsdr = mdb.ExchangeRequestDetailsDatas.Single(a => a.Id == ddr.ExchangeOrPurchaseDetailsId); // if (decimal.Parse(txtQty.Text) > detailsdr.Qty) // { // Response.Write("<script>alert('لا يمكن ان تكون الكمية المرتجعة اكبر من الكمية الموجوده في طلب الصرف')</script>"); // return; // } // if (decimal.Parse(txtFreeQty.Text) > detailsdr.FreeQty) // { // Response.Write("<script>alert('لا يمكن ان تكون الكمية المجانية المرتجعة اكبر من الكمية الموجوده في طلب الصرف')</script>"); // return; // } // } // ddr.RefluxQty = decimal.Parse(txtQty.Text); // ddr.RefluxFreeQty = decimal.Parse(txtFreeQty.Text); // mdb.SaveChanges(); // gvReflux.DataBind(); // } // catch { } //} protected void btnSave_Click(object sender, ImageClickEventArgs e) { ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.RefluxDetailsData ddr = mdb.RefluxDetailsDatas.Single(a => a.Id == long.Parse(RefluxDetailsId.Value)); if (ddr.RefluxHeaderData.OrderType == 1) { ADAM.DataBase.PurchaseOredrDetail Pdr = mdb.PurchaseOredrDetails.Single(a => a.Id == ddr.ExchangeOrPurchaseDetailsId); if (Pdr.Status == 2) { Pdr.IsClosed = 1; } else { Response.Write("<script>alert('لا يمكن ارتجاع هذا الصنف حيث انه ليس في حالة جديد لطلب الشراء')</script>"); return; } } else if (ddr.RefluxHeaderData.OrderType == 2) { ADAM.DataBase.ExchangeRequestDetailsData Edr = mdb.ExchangeRequestDetailsDatas.Single(a => a.Id == ddr.ExchangeOrPurchaseDetailsId); if (Edr.Status == 0) { Response.Write("<script>alert('لا يمكن ارتجاع هذا الصنف حيث انه لم يتم صرفه')</script>"); return; } else if (Edr.Status != 0) { long incommingOrder = 0; long AuditDetailsId = 0; long MovementnameId = 6; var incomeRows = from a in mdb.ItemMovements where (a.MovmentnameId == 3 || a.MovmentnameId == 6) && a.ItemId == ddr.ItemId && a.ItemColorId == ddr.ItemColorId && a.IncommingOrderNo == long.Parse(txtIncommingOrder.Text) select a; if (incomeRows.Count() <= 0) { Response.Write("<script>alert('من فضلك تأكد من رقم أذن الوارد')</script>"); return; } if (!string.IsNullOrEmpty(txtIncommingOrder.Text) && long.Parse(txtIncommingOrder.Text) > 0) { incommingOrder = long.Parse(txtIncommingOrder.Text); MovementnameId = 3; } ADAM.DataBase.ItemMovement itmmovdr = mdb.ItemMovements.Single(a => a.IncommingOrderNo == incommingOrder && a.AuditDetailsId == AuditDetailsId && a.MovmentnameId == MovementnameId && a.ItemColorId == ddr.ItemColorId && a.ItemId == ddr.ItemId); itmmovdr.MainQtyOut = itmmovdr.MainQtyOut - (ddr.RefluxQty + ddr.Bounce); itmmovdr.AdditionalQtyOut = itmmovdr.AdditionalQtyOut - ddr.RefluxFreeQty; ADAM.DataBase.ItemMovement Nmov = new DataBase.ItemMovement(); Nmov.AdditionalQty = ddr.RefluxFreeQty; Nmov.AuditDetailsId = AuditDetailsId; Nmov.DocmentId = ddr.Id; Nmov.IncommingOrderNo = incommingOrder; Nmov.ItemColorId = itmmovdr.ItemColorId; Nmov.ItemId = ddr.ItemId; Nmov.LocatioId = itmmovdr.LocatioId; Nmov.ItemUnitId = itmmovdr.ItemUnitId; Nmov.MainQty = ddr.RefluxQty + ddr.Bounce; Nmov.MainQtyOut = Nmov.AdditionalQtyOut = 0; Nmov.MovementDate = DateTime.Now; Nmov.MovmentnameId = 13; Nmov.RecDate = DateTime.Now; Nmov.StoreId = itmmovdr.StoreId; Nmov.SupplyOrderDetailsId = itmmovdr.SupplyOrderDetailsId; Nmov.ParentItemMoveMentId = itmmovdr.Id; mdb.ItemMovements.Add(Nmov); } ddr.Status = 1; } mdb.SaveChanges(); gvReflux.DataBind(); }
protected void gvBalance_SelectedIndexChanged(object sender, EventArgs e) { try { long MovementId = long.Parse(gvBalance.SelectedDataKey.Value.ToString()); TextBox txtQty = gvBalance.SelectedRow.FindControl("txtQty") as TextBox; TextBox txtTester = gvBalance.SelectedRow.FindControl("txtTester") as TextBox; if (string.IsNullOrEmpty(txtQty.Text) && string.IsNullOrEmpty(txtTester.Text)) { return; } ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.ItemMovement movdr = mdb.ItemMovements.Single(a => a.Id == MovementId); if (!string.IsNullOrEmpty(txtQty.Text)) { ADAM.DataBase.ItemMovement newmovdr = new DataBase.ItemMovement(); newmovdr.AdditionalQty = 0; newmovdr.AdditionalQtyOut = 0; newmovdr.AuditDetailsId = movdr.AuditDetailsId; newmovdr.DocmentId = 0; newmovdr.IncommingOrderNo = movdr.IncommingOrderNo; newmovdr.ItemColorId = movdr.ItemColorId; newmovdr.ItemId = movdr.ItemId; newmovdr.ItemUnitId = movdr.ItemUnitId; newmovdr.LocatioId = movdr.LocatioId; newmovdr.MainQty = -1 * decimal.Parse(txtQty.Text); newmovdr.MainQtyOut = 0; newmovdr.MovementDate = DateTime.Now; newmovdr.MovmentnameId = 18; newmovdr.RecDate = DateTime.Now; newmovdr.StoreId = movdr.StoreId; newmovdr.SupplyOrderDetailsId = movdr.SupplyOrderDetailsId; newmovdr.ParentItemMoveMentId = movdr.Id; mdb.ItemMovements.Add(newmovdr); movdr.MainQtyOut += decimal.Parse(txtQty.Text); movdr.AdditionalQty += decimal.Parse(txtQty.Text); ADAM.DataBase.ItemMovement newmovddr = new DataBase.ItemMovement(); newmovddr.AdditionalQty = decimal.Parse(txtQty.Text); newmovddr.AdditionalQtyOut = 0; newmovddr.AuditDetailsId = movdr.AuditDetailsId; newmovddr.DocmentId = 0; newmovddr.IncommingOrderNo = movdr.IncommingOrderNo; newmovddr.ItemColorId = movdr.ItemColorId; newmovddr.ItemId = movdr.ItemId; newmovddr.ItemUnitId = movdr.ItemUnitId; newmovddr.LocatioId = movdr.LocatioId; newmovddr.MainQty = 0; newmovddr.MainQtyOut = 0; newmovddr.MovementDate = DateTime.Now; newmovddr.MovmentnameId = 15; newmovddr.RecDate = DateTime.Now; newmovddr.StoreId = movdr.StoreId; newmovddr.SupplyOrderDetailsId = movdr.SupplyOrderDetailsId; newmovddr.ParentItemMoveMentId = movdr.Id; mdb.ItemMovements.Add(newmovddr); } if (!string.IsNullOrEmpty(txtTester.Text)) { ADAM.DataBase.ItemMovement newmovdr = new DataBase.ItemMovement(); newmovdr.AdditionalQty = -1 * decimal.Parse(txtTester.Text); newmovdr.AdditionalQtyOut = 0; newmovdr.AuditDetailsId = movdr.AuditDetailsId; newmovdr.DocmentId = 0; newmovdr.IncommingOrderNo = movdr.IncommingOrderNo; newmovdr.ItemColorId = movdr.ItemColorId; newmovdr.ItemId = movdr.ItemId; newmovdr.ItemUnitId = movdr.ItemUnitId; newmovdr.LocatioId = movdr.LocatioId; newmovdr.MainQty = 0; newmovdr.MainQtyOut = 0; newmovdr.MovementDate = DateTime.Now; newmovdr.MovmentnameId = 19; newmovdr.RecDate = DateTime.Now; newmovdr.StoreId = movdr.StoreId; newmovdr.SupplyOrderDetailsId = movdr.SupplyOrderDetailsId; newmovdr.ParentItemMoveMentId = movdr.Id; mdb.ItemMovements.Add(newmovdr); movdr.AdditionalQtyOut += decimal.Parse(txtTester.Text); movdr.MainQty += decimal.Parse(txtTester.Text); ADAM.DataBase.ItemMovement newmovddr = new DataBase.ItemMovement(); newmovddr.AdditionalQty = 0; newmovddr.AdditionalQtyOut = 0; newmovddr.AuditDetailsId = movdr.AuditDetailsId; newmovddr.DocmentId = 0; newmovddr.IncommingOrderNo = movdr.IncommingOrderNo; newmovddr.ItemColorId = movdr.ItemColorId; newmovddr.ItemId = movdr.ItemId; newmovddr.ItemUnitId = movdr.ItemUnitId; newmovddr.LocatioId = movdr.LocatioId; newmovddr.MainQty = decimal.Parse(txtTester.Text); newmovddr.MainQtyOut = 0; newmovddr.MovementDate = DateTime.Now; newmovddr.MovmentnameId = 14; newmovddr.RecDate = DateTime.Now; newmovddr.StoreId = movdr.StoreId; newmovddr.SupplyOrderDetailsId = movdr.SupplyOrderDetailsId; newmovddr.ParentItemMoveMentId = movdr.Id; mdb.ItemMovements.Add(newmovddr); } mdb.SaveChanges(); gvBalance.DataBind(); gvItems.DataBind(); } catch { } }