protected void btnSave_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 1; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } try { ADAM.DataBase.ADAMConnectionString db = new DataBase.ADAMConnectionString(); long SupplierAccount = db.SupplierDatas.Single(a => a.Id == long.Parse(ddlVendorName.SelectedValue)).AccountId; long BoxAccount = long.Parse(ddlBoxName.SelectedValue); csJournal csAddjournal = new csJournal(); long JournalHeaderId = csAddjournal.InsertIntoJournalHeader(0, DateTime.Now, 15, "قيد فاتورة شراء", 0, long.Parse(hfSupplyheaderId.Value)); csAddjournal.InsertIntoJournalDetails(SupplierAccount, long.Parse(ddlCostCenterName.SelectedValue), decimal.Parse(lblBillPrice.Text), 0, JournalHeaderId, "من حـ / المورد"); csAddjournal.InsertIntoJournalDetails(BoxAccount, long.Parse(ddlCostCenterName.SelectedValue), 0, decimal.Parse(lblBillPrice.Text), JournalHeaderId, "الي حـ / الصندوق"); ADAM.DataBase.SupplyOrderHeader SOHdr = db.SupplyOrderHeaders.Single(a => a.Id == long.Parse(hfSupplyheaderId.Value.ToString())); SOHdr.Posted = 1; db.SaveChanges(); } catch { } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { if (string.IsNullOrEmpty(txtDebit.Text) || txtDebit.Text == "0") { if (string.IsNullOrEmpty(txtCredit.Text) || txtCredit.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من أدخال قيمة في المدين او الدائن')</script>"); return; } } if (string.IsNullOrEmpty(txtCredit.Text) || txtCredit.Text == "0") { if (string.IsNullOrEmpty(txtDebit.Text) || txtDebit.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من أدخال قيمة في المدين او الدائن')</script>"); return; } } BasicData.csJournal InsertJournal = new csJournal(); if (hfJournalHeaderId.Value == "0") { long JournalHeaderId = InsertJournal.InsertIntoJournalHeader(0, DateTime.Now, 8, "قيد أفتتاحي", 0, 0); hfJournalHeaderId.Value = JournalHeaderId.ToString(); } InsertJournal.InsertIntoJournalDetails(long.Parse(ddlAccountName.SelectedValue), 1, decimal.Parse(txtDebit.Text), decimal.Parse(txtCredit.Text), long.Parse(hfJournalHeaderId.Value), txtNote.Text); gvJournalDetails.DataBind(); EmpData(); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 1; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } try { ADAM.DataBase.ADAMConnectionString db = new DataBase.ADAMConnectionString(); long SalesCost = db.AccountHelpers.Single(a => a.Id == 2).AccountId; long StoreAccount = db.ItemTypes.Single(a => a.Id == db.ExchangeRequestDetailsDatas.Single(aa => aa.ExchangeRequestHeaderDataId == long.Parse(hfExchangeheaderId.Value.ToString())).ItemTypeId).AccountId; long ClientAccount = db.ClientDatas.Single(a => a.Id == long.Parse(ddlClient.SelectedValue)).AccountId; long SalesAccount = db.AccountHelpers.Single(a => a.Id == 1).AccountId; csJournal csAddjournal = new csJournal(); long JournalHeaderId = csAddjournal.InsertIntoJournalHeader(0, DateTime.Now, int.Parse(ddlExchangeRequestType.SelectedValue), "قيد فاتورة بيع", 0, long.Parse(hfExchangeheaderId.Value)); csAddjournal.InsertIntoJournalDetails(SalesAccount, long.Parse(ddlCostCenterName.SelectedValue), decimal.Parse(ViewState["AllItemCost"].ToString()), 0, JournalHeaderId, "من حـ / تكلفة المبيعات"); csAddjournal.InsertIntoJournalDetails(StoreAccount, long.Parse(ddlCostCenterName.SelectedValue), 0, decimal.Parse(ViewState["AllItemCost"].ToString()), JournalHeaderId, "الي حـ / المخزن"); csAddjournal.InsertIntoJournalDetails(ClientAccount, long.Parse(ddlCostCenterName.SelectedValue), decimal.Parse(lblBillPrice.Text), 0, JournalHeaderId, "من حـ / العميل"); csAddjournal.InsertIntoJournalDetails(SalesAccount, long.Parse(ddlCostCenterName.SelectedValue), 0, decimal.Parse(lblBillPrice.Text), JournalHeaderId, "الي حـ / المبيعات"); ADAM.DataBase.ExchangeRequestHeaderData ERHdr = db.ExchangeRequestHeaderDatas.Single(a => a.Id == long.Parse(hfExchangeheaderId.Value)); ERHdr.Posted = 1; db.SaveChanges(); hfExchangeheaderId.Value = "0"; gvExchangeData.DataBind(); } catch { } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { if (Session["UserID"] == null) { Response.Redirect("~/BasicData/webLogIn.aspx"); } int userid = int.Parse(Session["UserID"].ToString()); int operationid = 1; csGetPermission Per = new csGetPermission(); if (!Per.getPermission(userid, pageid, operationid)) { Response.Redirect("~/BasicData/webHomePage.aspx"); } if (string.IsNullOrEmpty(txtDebit.Text) || txtDebit.Text == "0") { if (string.IsNullOrEmpty(txtCredit.Text) || txtCredit.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من أدخال قيمة في المدين او الدائن')</script>"); return; } } if (string.IsNullOrEmpty(txtCredit.Text) || txtCredit.Text == "0") { if (string.IsNullOrEmpty(txtDebit.Text) || txtDebit.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من أدخال قيمة في المدين او الدائن')</script>"); return; } } BasicData.csJournal InsertJournal = new csJournal(); if (hfJournalHeaderId.Value == "0") { long JournalHeaderId = InsertJournal.InsertIntoJournalHeader(long.Parse(txtjournalCode.Text), DateTime.Parse(txtjournalDate.Text), int.Parse(ddlJournaType.SelectedValue), txtJournalNote.Text, 0, 0); hfJournalHeaderId.Value = JournalHeaderId.ToString(); } InsertJournal.InsertIntoJournalDetails(long.Parse(ddlAccountName.SelectedValue), long.Parse(ddlCostCenter.SelectedValue), decimal.Parse(txtDebit.Text), decimal.Parse(txtCredit.Text), long.Parse(hfJournalHeaderId.Value), txtNote.Text); gvJournalDetails.DataBind(); EmpData(); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { try { GetNum(); #region Validation if (string.IsNullOrEmpty(txtMasterAccountQty.Text) || txtMasterAccountQty.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من ادخال المبالغ بشكل صحيح')</script>"); return; } if (string.IsNullOrEmpty(txtDetailsAccountQty.Text) || txtDetailsAccountQty.Text == "0") { Response.Write("<script>alert('من فضلك تأكد من ادخال المبالغ بشكل صحيح')</script>"); return; } if (ddlHeaderAccountName.SelectedValue == "0" || ddlDetailsAccountName.SelectedValue == "0") { Response.Write("<script>alert('من فضلك تأكد من اختيار الحساب بشكل صحيح')</script>"); return; } if (string.IsNullOrEmpty(txtDocNo.Text) || string.IsNullOrEmpty(txtDocDate.Text)) { Response.Write("<script>alert('من فضلك تأكد من ادخال كافة البيانات بشكل صحيح')</script>"); return; } if (ddlDetailsCostCenter.SelectedValue == "0" || ddlHeaderCostCenter.SelectedValue == "0") { Response.Write("<script>alert('من فضلك تأكد من ادخال مراكز التكلفة بشكل صحيح')</script>"); return; } if (string.IsNullOrEmpty(txtDetailsNote.Text)) { txtDetailsNote.Text = "-"; } if (string.IsNullOrEmpty(txtHeaderNote.Text)) { txtHeaderNote.Text = "-"; } #endregion ADAM.DataBase.ADAMConnectionString db = new DataBase.ADAMConnectionString(); csJournal Journal = new csJournal(); if (hfDocHeaderId.Value == "0") { ADAM.DataBase.DocumentHeader Docdr = new DataBase.DocumentHeader(); Docdr.AccountId = long.Parse(ddlHeaderAccountName.SelectedValue); Docdr.CostCenterId = long.Parse(ddlHeaderCostCenter.SelectedValue); Docdr.DocDate = DateTime.Parse(txtDocDate.Text); Docdr.DocNo = long.Parse(txtDocNo.Text); Docdr.DocPaymentType = 1; // نقدا Docdr.DocType = 1; // نوع المستند صرف Docdr.MasterAccountQty = decimal.Parse(txtMasterAccountQty.Text); Docdr.Notes = txtHeaderNote.Text; Docdr.HPriceInArabic = ConNumToAr.RealString(txtMasterAccountQty.Text); db.DocumentHeaders.Add(Docdr); db.SaveChanges(); hfDocHeaderId.Value = Docdr.Id.ToString(); hfJournalId.Value = (Journal.InsertIntoJournalHeader(0, Docdr.DocDate, 6, "سند صرف", 0, Docdr.Id)).ToString(); Journal.InsertIntoJournalDetails(Docdr.AccountId, Docdr.CostCenterId, 0, decimal.Parse(txtMasterAccountQty.Text), long.Parse(hfJournalId.Value), (" الي حـ / :" + db.Accounts.Single(a => a.Id == long.Parse(ddlHeaderAccountName.SelectedValue)).AccountName)); } ADAM.DataBase.DocumentDetail docddr = new DataBase.DocumentDetail(); docddr.AccountId = long.Parse(ddlDetailsAccountName.SelectedValue); docddr.CostCenterId = long.Parse(ddlDetailsCostCenter.SelectedValue); docddr.DetailsAccountQty = decimal.Parse(txtDetailsAccountQty.Text); docddr.DocHeaderId = long.Parse(hfDocHeaderId.Value); docddr.Notes = txtDetailsNote.Text; docddr.DPriceInArabic = ConNumToAr.RealString(txtDetailsAccountQty.Text); db.DocumentDetails.Add(docddr); db.SaveChanges(); Journal.InsertIntoJournalDetails(docddr.AccountId, docddr.CostCenterId, docddr.DetailsAccountQty, 0, long.Parse(hfJournalId.Value), ("من حـ / :" + db.Accounts.Single(a => a.Id == long.Parse(ddlDetailsAccountName.SelectedValue)).AccountName)); gvDocDetails.DataBind(); } catch { } }
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"); }