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 btnShowData_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 3; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } if (string.IsNullOrEmpty(txtOrderNo.Text)) { Response.Write("<script>alert('من فضلك تأكد من ادخال رقم الطلب')</script>"); return; } ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); var Row = from a in mdb.ProductionHeaderOrders where a.ProductionNo == long.Parse(txtOrderNo.Text) select a; if (Row.Count() > 0) { ADAM.DataBase.ProductionHeaderOrder headerdr = mdb.ProductionHeaderOrders.Single(a => a.ProductionNo == long.Parse(txtOrderNo.Text)); hfHeaderId.Value = headerdr.Id.ToString(); txtDate.Text = headerdr.ProductionDate.ToString("yyyy-MM-dd"); for (int GRow = 0; GRow < gvProductionOrderData.Rows.Count; GRow++) { TextBox txtQty = gvProductionOrderData.Rows[GRow].FindControl("txtQty") as TextBox; long ItemContentHeaderId = long.Parse(gvProductionOrderData.DataKeys[GRow].Value.ToString()); var dRows = from a in mdb.ProductionDetailsOrders where a.ContentHeaderId == ItemContentHeaderId && a.ProductionHeaderOrderId == long.Parse(hfHeaderId.Value) select a; if (dRows.Count() > 0) { ADAM.DataBase.ProductionDetailsOrder ddr = mdb.ProductionDetailsOrders.Single(a => a.ContentHeaderId == ItemContentHeaderId && a.ProductionHeaderOrderId == long.Parse(hfHeaderId.Value)); txtQty.Text = ddr.Qty.ToString(); } } } else { Response.Write("<script>alert('من فضلك تأكد من رقم الطلب')</script>"); return; } }
protected void btnEdit_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 2; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.ProductionHeaderOrder headerdr = new DataBase.ProductionHeaderOrder(); if (hfHeaderId.Value != "0") { headerdr = mdb.ProductionHeaderOrders.Single(a => a.Id == long.Parse(hfHeaderId.Value)); } else { Response.Write("<script>alert('لا يمكن التعديل الا بعد الحفظ في قاعدة البيانات')</script>"); return; } for (int GRow = 0; GRow < gvProductionOrderData.Rows.Count; GRow++) { TextBox txtQty = gvProductionOrderData.Rows[GRow].FindControl("txtQty") as TextBox; if (!string.IsNullOrEmpty(txtQty.Text)) { if (decimal.Parse(txtQty.Text) <= 0) { Response.Write("<script>alert('من فضلك يجب ان تكون الكمية اكبر من الصفر')</script>"); return; } long ItemContentHeaderId = long.Parse(gvProductionOrderData.DataKeys[GRow].Value.ToString()); ADAM.DataBase.ProductionDetailsOrder detailsdr = mdb.ProductionDetailsOrders.Single(a => a.Status == 0 && a.ContentHeaderId == ItemContentHeaderId && a.ProductionHeaderOrderId == long.Parse(hfHeaderId.Value) && a.ProductionHeaderOrder.ProductionNo == long.Parse(txtOrderNo.Text)); detailsdr.Qty = decimal.Parse(txtQty.Text); } } mdb.SaveChanges(); btnNew_Click(sender, e); }