protected void gvSupplier_SelectedIndexChanged(object sender, EventArgs e) { divData.Visible = true; divSupplier.Visible = false; ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.SupplierData dr = mdb.SupplierDatas.Single(a => a.Id == long.Parse(gvSupplier.SelectedDataKey.Value.ToString())); ddlSupplierName.SelectedValue = dr.Id.ToString(); txtSupplierCode.Text = dr.Code.ToString(); }
protected void txtSupplierCode_TextChanged(object sender, EventArgs e) { try { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.SupplierData dr = Mdb.SupplierDatas.Single(a => a.Code == long.Parse(txtSupplierCode.Text)); ddlSupplier.SelectedValue = dr.Id.ToString(); } catch { return; } }
private void DeleteData() { try { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.SupplierData dr = Mdb.SupplierDatas.Single(a => a.Code == long.Parse(txtCode.Text) && a.SupplierTypeId == long.Parse(ddlSupplierType.SelectedValue)); Mdb.SupplierDatas.Remove(dr); Mdb.SaveChanges(); Response.Write("<script>alert('تمت عملية الحذف نجاح')</script>"); } catch { Response.Write("<script>alert('خطأ أثناء الحذف من فضلك تأكد من ادخال البيانات بشكل صحيح او من الاتصال بقاعدة البيانات')</script>"); } }
private void EditData() { try { if (ValidationData()) { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.SupplierData dr = Mdb.SupplierDatas.Single(a => a.Code == long.Parse(txtCode.Text) && a.SupplierTypeId == long.Parse(ddlSupplierType.SelectedValue)); if (Validation()) { dr.Address = txtAddress.Text; dr.Email = txtEmail.Text; dr.Fax = txtFax.Text; dr.FirstMobile = txtFirstMobile.Text; dr.FirstName = txtFirstName.Text; dr.FirstPhone = txtFirstPhone.Text; dr.IdNo = txtIdNo.Text; dr.LastName = txtLastName.Text; dr.SecondMobile = txtSecondMobile.Text; dr.SecondPhone = txtSecondPhone.Text; dr.JobId = long.Parse(ddlJob.SelectedValue); dr.Sex = int.Parse(ddlSex.SelectedValue); dr.CountryId = long.Parse(ddlCountry.SelectedValue); dr.CityId = long.Parse(ddlCity.SelectedValue); dr.Status = int.Parse(ddlStatus.SelectedValue); dr.GovernorateId = long.Parse(ddlGovernorate.SelectedValue); dr.SupplierTypeId = long.Parse(ddlSupplierType.SelectedValue); dr.AreaId = long.Parse(ddlArea.SelectedValue); var AccountRow = from a in Mdb.Accounts where a.AccountCode == long.Parse(txtAccountCode.Text) select a; if (AccountRow.Count() > 0) { ADAM.DataBase.Account accdr = Mdb.Accounts.Single(a => a.AccountCode == long.Parse(txtAccountCode.Text)); dr.AccountId = accdr.Id; } else { Response.Write("<script>alert('هذا المورد ليس له حساب من فضلك تأكد من انشاء حساب اولا قبل التعديل')</script>"); return; } Mdb.SaveChanges(); Response.Write("<script>alert('تمت عملية التعديل بنجاح')</script>"); } else { Response.Write("<script>alert('هذا الكود غير موجود بقاعدة البيانات')</script>"); } } } catch { Response.Write("<script>alert('خطأ أثناء التعديل من فضلك تأكد من ادخال البيانات بشكل صحيح او الاتصال بقاعدة البيانات ')</script>"); } }
private void ShowData() { try { ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString(); var Rows = from a in Mdb.SupplierDatas where a.Code == long.Parse(txtCode.Text) && a.SupplierTypeId == long.Parse(ddlSupplierType.SelectedValue) select a; if (Rows.Count() > 0) { ADAM.DataBase.SupplierData dr = Mdb.SupplierDatas.Single(a => a.Code == long.Parse(txtCode.Text) && a.SupplierTypeId == long.Parse(ddlSupplierType.SelectedValue)); txtFirstName.Text = dr.FirstName; txtLastName.Text = dr.LastName; txtFirstPhone.Text = dr.FirstPhone; txtSecondPhone.Text = dr.SecondPhone; txtFirstMobile.Text = dr.FirstMobile; txtSecondMobile.Text = dr.SecondMobile; txtFax.Text = dr.Fax; txtEmail.Text = dr.Email; txtAddress.Text = dr.Address; txtIdNo.Text = dr.IdNo; ddlJob.SelectedValue = dr.JobId.ToString(); ddlSex.SelectedValue = dr.Sex.ToString(); ddlCountry.SelectedValue = dr.CountryId.ToString(); ddlStatus.SelectedValue = dr.Status.ToString(); ddlCity.DataBind(); ddlCity.SelectedValue = dr.CityId.ToString(); ddlSupplierType.SelectedValue = dr.SupplierTypeId.ToString(); ddlGovernorate.DataBind(); ddlGovernorate.SelectedValue = dr.GovernorateId.ToString(); ddlArea.DataBind(); ddlArea.SelectedValue = dr.AreaId.ToString(); txtAccountCode.Text = dr.AccountId.ToString(); var AccountRow = from a in Mdb.Accounts where a.Id == dr.AccountId select a; if (AccountRow.Count() > 0) { ADAM.DataBase.Account accdr = Mdb.Accounts.Single(a => a.Id == dr.AccountId); txtAccountCode.Text = accdr.AccountCode.ToString(); } else { Response.Write("<script>alert('هذا المورد ليس له حساب من فضلك تأكد من انشاء حساب')</script>"); } } else { Response.Write("<script>alert('من فضلك تأكد من كود المورد')</script>"); } } catch { Response.Write("<script>alert('خطأ أثناء عرض البيانات من فضلك تأكد من الكود او من الاتصال بقاعدة البيانات')</script>"); } }
private void GetNum() { ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); var Rows = from a in mdb.SupplierDatas where a.SupplierTypeId == long.Parse(ddlSupplierType.SelectedValue) orderby a.Id descending select a; if (Rows.Count() == 0) { txtCode.Text = "1"; } else { ADAM.DataBase.SupplierData dr = Rows.First(); txtCode.Text = (dr.Code + 1).ToString(); } }
protected void ddlClientName_SelectedIndexChanged(object sender, EventArgs e) { ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); ADAM.DataBase.SupplierData dr = mdb.SupplierDatas.Single(a => a.Id == long.Parse(ddlSupplierName.SelectedValue)); txtSupplierCode.Text = dr.Code.ToString(); }
protected void btnConform_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 7; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } if (string.IsNullOrEmpty(txtAuditNo.Text)) { Response.Write("<script>alert('من فضلك تأكد من ادخال رقم اخطار الفحص')</script>"); return; } ADAM.DataBase.ADAMConnectionString mdb = new DataBase.ADAMConnectionString(); for (int Row = 0; Row < gvAuditData.Rows.Count; Row++) { CheckBox chkChoose = gvAuditData.Rows[Row].FindControl("chkChoose") as CheckBox; if (chkChoose.Checked) { DropDownList ddlEmployee = gvAuditData.Rows[Row].FindControl("ddlEmployee") as DropDownList; TextBox txtAcceptQty = gvAuditData.Rows[Row].FindControl("txtAcceptQty") as TextBox; TextBox txtRefused = gvAuditData.Rows[Row].FindControl("txtRefused") as TextBox; TextBox txtNote = gvAuditData.Rows[Row].FindControl("txtNote") as TextBox; DropDownList ddlLocation = gvAuditData.Rows[Row].FindControl("ddlLocation") as DropDownList; TextBox txtFreeAcceptQty = gvAuditData.Rows[Row].FindControl("txtFreeAcceptQty") as TextBox; TextBox txtfreeRefusedQty = gvAuditData.Rows[Row].FindControl("txtfreeRefusedQty") as TextBox; if (ddlEmployee.SelectedValue == "0" || ddlLocation.SelectedValue == "0" || string.IsNullOrEmpty(txtAcceptQty.Text) || string.IsNullOrEmpty(txtRefused.Text) || string.IsNullOrEmpty(txtFreeAcceptQty.Text) || string.IsNullOrEmpty(txtfreeRefusedQty.Text)) { Response.Write("<script>alert('من فضلك تأكد من ادخال كل البيانات بشكل صحيح')</script>"); return; } decimal Qty = decimal.Parse(gvAuditData.Rows[Row].Cells[2].Text); if ((decimal.Parse(txtAcceptQty.Text) + decimal.Parse(txtRefused.Text)) != Qty) { Response.Write("<script>alert('يجب ان يساوي مجموع الكمية المقبولة والكمية المرفوضة الكمية المستلمة')</script>"); Response.Write("<script>alert(' الكمية المستلمة هي " + Qty + "')</script>"); return; } decimal AllAuditQty = 0; long AuditDetailId = long.Parse(gvAuditData.DataKeys[Row].Value.ToString()); ADAM.DataBase.AuditDetail auddr = mdb.AuditDetails.Single(a => a.Id == AuditDetailId); ADAM.DataBase.RecordReceiptDetail rrdr = mdb.RecordReceiptDetails.Single(a => a.Id == auddr.RecordReceiptDetailsId); ADAM.DataBase.SupplyOrderDetail supdr = mdb.SupplyOrderDetails.Single(a => a.Id == rrdr.SupplyOrderDetailsId); if (supdr.ItemPrice <= 0) { Response.Write("<script>alert('امر التوريد رقم " + supdr.SupplyOrderHeader.SupplyOrderNo + "والمرتبط بهذا الاجراء من فضلك قم بتسعير امر التوريد')</script>"); #region DelJournal for (int DelRow = 0; DelRow < gvAuditData.Rows.Count; DelRow++) { if (DelRow > Row) { continue; } chkChoose = gvAuditData.Rows[DelRow].FindControl("chkChoose") as CheckBox; if (chkChoose.Checked) { ADAM.DataBase.AuditDetail Delauddr = mdb.AuditDetails.Single(a => a.Id == AuditDetailId); ADAM.DataBase.RecordReceiptDetail Delrrdr = mdb.RecordReceiptDetails.Single(a => a.Id == auddr.RecordReceiptDetailsId); ADAM.DataBase.SupplyOrderDetail Delsupdr = mdb.SupplyOrderDetails.Single(a => a.Id == rrdr.SupplyOrderDetailsId); var JourHeaderRows = from a in mdb.JournalHeaders where a.DocId == Delsupdr.Id select a; if (JourHeaderRows.Count() > 0) { ADAM.DataBase.JournalHeader Deljournal = mdb.JournalHeaders.Single(a => a.DocId == Delsupdr.Id); var DelJournalRow = from a in mdb.JournalDetails where a.JournalId == Deljournal.Id select a; if (DelJournalRow.Count() > 0) { foreach (ADAM.DataBase.JournalDetail delJornalDetail in DelJournalRow) { mdb.JournalDetails.Remove(delJornalDetail); } mdb.SaveChanges(); } } } } #endregion return; } ADAM.DataBase.PurchaseOredrDetail Purddr = mdb.PurchaseOredrDetails.Single(a => a.Id == supdr.PurchaseOrderDetailsId); int ItemColorId = Purddr.ItemColorId; var RecDetails = from a in mdb.RecordReceiptDetails where a.SupplyOrderDetailsId == supdr.Id select a; foreach (ADAM.DataBase.RecordReceiptDetail recdr in RecDetails) { ADAM.DataBase.AuditDetail auditdr = mdb.AuditDetails.Single(a => a.RecordReceiptDetailsId == recdr.Id); AllAuditQty = AllAuditQty + auditdr.AcceptQty; } AllAuditQty = AllAuditQty + decimal.Parse(txtAcceptQty.Text); if (AllAuditQty > Purddr.ConformQty) { Response.Write("<script>alert('لا يمكن ان تكون اجمالي الكميات المستلمة اكبر من كمية طلب الشراء المعتمدة')</script>"); return; } #region Update AuditDetails auddr.EmployeeId = long.Parse(ddlEmployee.SelectedValue); auddr.AcceptQty = decimal.Parse(txtAcceptQty.Text); auddr.RefusedQty = decimal.Parse(txtRefused.Text); if (!string.IsNullOrEmpty(txtNote.Text)) { auddr.Note = txtNote.Text; } auddr.AcceptfreeQty = decimal.Parse(txtFreeAcceptQty.Text); auddr.RefusedFreeQty = decimal.Parse(txtfreeRefusedQty.Text); #endregion long UnitId = mdb.Items.Single(a => a.Id == rrdr.ItemId).ItemunitId; //----------------------------------------------------------------------- #region Insert IntoIncommingOrderTable long IncomOrderNo = GetIncoOrderData(long.Parse(ddlItemType.SelectedValue.ToString())); ADAM.DataBase.IncommingOrderData Incdr = new DataBase.IncommingOrderData(); Incdr.AuditDetailsId = auddr.Id; Incdr.FreeItemPrice = 0; Incdr.IncommingOrderNo = IncomOrderNo; Incdr.ItemPrice = supdr.ItemPrice; Incdr.ItemTypeId = long.Parse(ddlItemType.SelectedValue.ToString()); Incdr.RecordReceiptDetailsId = rrdr.Id; Incdr.LocationId = int.Parse(ddlLocation.SelectedValue); mdb.IncommingOrderDatas.Add(Incdr); #endregion //------------------------------------------------------------------------ #region Insert AcceptQty if (decimal.Parse(txtAcceptQty.Text) > 0) { ADAM.DataBase.ItemMovement itmdr = new DataBase.ItemMovement(); itmdr.AdditionalQty = decimal.Parse(txtFreeAcceptQty.Text) * -1; itmdr.DocmentId = auddr.Id; itmdr.ItemId = rrdr.ItemId; itmdr.MainQty = decimal.Parse(txtAcceptQty.Text) * -1; itmdr.MovementDate = DateTime.Now; itmdr.MovmentnameId = 2; itmdr.RecDate = DateTime.Now; itmdr.StoreId = 1; var Rows = from a in mdb.ItemLocations where a.ItemTypeId == int.Parse(ddlItemType.SelectedValue) select a; itmdr.LocatioId = Rows.First().Id; itmdr.ItemUnitId = UnitId; itmdr.SupplyOrderDetailsId = rrdr.SupplyOrderDetailsId; itmdr.ItemColorId = ItemColorId; itmdr.IncommingOrderNo = 0; itmdr.AuditDetailsId = auddr.Id; itmdr.AdditionalQtyOut = 0; itmdr.MainQtyOut = 0; itmdr.ParentItemMoveMentId = 0; mdb.ItemMovements.Add(itmdr); ADAM.DataBase.ItemMovement Nitmdr = new DataBase.ItemMovement(); Nitmdr.AdditionalQty = decimal.Parse(txtFreeAcceptQty.Text); Nitmdr.DocmentId = auddr.Id; Nitmdr.ItemId = rrdr.ItemId; Nitmdr.MainQty = decimal.Parse(txtAcceptQty.Text); Nitmdr.MovementDate = DateTime.Now; Nitmdr.MovmentnameId = 3; Nitmdr.RecDate = DateTime.Now; Nitmdr.StoreId = 2; Nitmdr.LocatioId = int.Parse(ddlLocation.SelectedValue); Nitmdr.ItemUnitId = UnitId; Nitmdr.SupplyOrderDetailsId = rrdr.SupplyOrderDetailsId; Nitmdr.ItemColorId = ItemColorId; Nitmdr.IncommingOrderNo = IncomOrderNo; Nitmdr.AuditDetailsId = auddr.Id; Nitmdr.AdditionalQtyOut = 0; Nitmdr.MainQtyOut = 0; Nitmdr.ParentItemMoveMentId = 0; mdb.ItemMovements.Add(Nitmdr); } #endregion #region Insert RefuseQty if (decimal.Parse(txtRefused.Text) > 0) { ADAM.DataBase.ItemMovement itmdr = new DataBase.ItemMovement(); itmdr.AdditionalQty = decimal.Parse(txtfreeRefusedQty.Text) * -1; itmdr.DocmentId = auddr.Id; itmdr.ItemId = rrdr.ItemId; itmdr.MainQty = decimal.Parse(txtRefused.Text) * -1; itmdr.MovementDate = DateTime.Now; itmdr.MovmentnameId = 4; itmdr.RecDate = DateTime.Now; itmdr.StoreId = 1; var Rows = from a in mdb.ItemLocations where a.ItemTypeId == int.Parse(ddlItemType.SelectedValue) select a; itmdr.LocatioId = Rows.First().Id; itmdr.ItemUnitId = UnitId; itmdr.SupplyOrderDetailsId = rrdr.SupplyOrderDetailsId; itmdr.ItemColorId = ItemColorId; itmdr.IncommingOrderNo = 0; itmdr.AuditDetailsId = auddr.Id; itmdr.AdditionalQtyOut = 0; itmdr.MainQtyOut = 0; itmdr.ParentItemMoveMentId = 0; mdb.ItemMovements.Add(itmdr); ADAM.DataBase.ItemMovement Nitmdr = new DataBase.ItemMovement(); Nitmdr.AdditionalQty = decimal.Parse(txtfreeRefusedQty.Text); Nitmdr.DocmentId = auddr.Id; Nitmdr.ItemId = rrdr.ItemId; Nitmdr.MainQty = decimal.Parse(txtRefused.Text); Nitmdr.MovementDate = DateTime.Now; Nitmdr.MovmentnameId = 5; Nitmdr.RecDate = DateTime.Now; Nitmdr.StoreId = 3; Nitmdr.LocatioId = Rows.First().Id; Nitmdr.ItemUnitId = UnitId; Nitmdr.SupplyOrderDetailsId = rrdr.SupplyOrderDetailsId; Nitmdr.ItemColorId = ItemColorId; Nitmdr.IncommingOrderNo = IncomOrderNo; Nitmdr.AuditDetailsId = auddr.Id; Nitmdr.AdditionalQtyOut = 0; Nitmdr.MainQtyOut = 0; Nitmdr.ParentItemMoveMentId = 0; mdb.ItemMovements.Add(Nitmdr); } #endregion Purddr.IsChecked = 7; if (AllAuditQty == Purddr.ConformQty) { Purddr.IsClosed = 1; } #region InsertJournalCode // من حـ / المخزن // الي حـ / المورد ADAM.DataBase.ItemType itemTypedr = mdb.ItemTypes.Single(a => a.Id == long.Parse(ddlItemType.SelectedValue)); ADAM.DataBase.SupplierData Supplierdr = mdb.SupplierDatas.Single(a => a.Id == supdr.SupplyOrderHeader.SupplierId); csJournal CsJornalRow = new csJournal(); long JournalHeaderId = CsJornalRow.InsertIntoJournalHeader(0, DateTime.Now, 9, "دخول البضاعة الي المخزن", 0, supdr.SupplyOrderHeaderId); CsJornalRow.InsertIntoJournalDetails(itemTypedr.AccountId, supdr.SupplyOrderHeader.CostCenter, (decimal.Parse(txtAcceptQty.Text) * supdr.ItemPrice), 0, JournalHeaderId, "من ح/ المخزن"); CsJornalRow.InsertIntoJournalDetails(Supplierdr.AccountId, supdr.SupplyOrderHeader.CostCenter, 0, (decimal.Parse(txtAcceptQty.Text) * supdr.ItemPrice), JournalHeaderId, "الي حـ / المورد"); #endregion } } mdb.SaveChanges(); Response.Redirect("~/StoreData/webConformAudit.aspx"); }