protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Ta_PayMoney] ([DateOfOperation] ,[Employee_Id] ,[Amount] ,[Notes] ,[Type]) VALUES (@1,@2,@3,@4,@5)"; dataObj.Execute(sql, DateTime.Parse(txtDate.Text), drpEmployee.SelectedItem.Value, float.Parse(txtAmount.Text), txtNotes.Text, "سند قبض"); string Up = @"UPDATE [dbo].[Ta_Employee] SET [Balance] = [Balance]-@1 WHERE [Id]=@2"; dataObj.Execute(Up, float.Parse(txtAmount.Text), drpEmployee.SelectedItem.Value); helper.cleartxt(UpdatePanel1); drpEmployee.SelectedIndex = 0; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnPuplish_Click(object sender, EventArgs e) { try { //MM-dd-yyyy string sql = "delete from [dbo].[MonthlyInstallmentsDetails] where code=@1"; databaseaccesslayerobj.Execute(sql, txtCode.Text); int year = DateTime.Now.Year; string InsertSql = "INSERT INTO [dbo].[MonthlyInstallmentsDetails] ([Code],[Date],[Amount]) VALUES (@1,@2,@3)"; int x = int.Parse(txtNum.Text); float Total = float.Parse(labTotal.Text) / x; for (int i = 1; i <= x; i++) { int num = (int.Parse(drpMonth.Text) + i - 1); if (num <= 12) { string date = num + "-" + drpDay.Text + "-" + year; databaseaccesslayerobj.Execute(InsertSql, txtCode.Text, date, Total); } else { string date = (num - 12) + "-" + (int.Parse(drpDay.Text) + 1) + "-" + year; databaseaccesslayerobj.Execute(InsertSql, txtCode.Text, date, Total); } } grdInstallment.DataSource = databaseaccesslayerobj.Selectdatatable("select [Date] as التاريخ,[Amount] as المبلغ from MonthlyInstallmentsDetails where code='" + txtCode.Text + "'"); grdInstallment.DataBind(); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Users] ([Name],[UserName],[Password],[Mobil],[Address]) VALUES(@1,@2,@3,@4,@5)"; dataobj.Execute(sql, TxtName.Text, txtUserName.Text, txtPassword.Text, txtMobil.Text, txtAddress.Text); string sql1 = @"select Id from [dbo].[Users] where [UserName]='" + txtUserName.Text + "' and [Password]='" + txtPassword.Text + "'"; DataTable dt = dataobj.Selectdatatable(sql1); for (int i = 0; i < grdSelect.Rows.Count; i++) { CheckBox c = (grdSelect.Rows[i].Cells[0].FindControl("btnCheckAll") as CheckBox); if (c.Checked == true) { string sql2 = @"INSERT INTO [dbo].[Application_Setting] ([User_Id],[Appl_Id],[IsVaild]) VALUES(@1,@2,@3)"; dataobj.Execute(sql2, dt.Rows[0]["Id"].ToString(), grdSelect.Rows[i].Cells[1].Text, true); } } helper.cleartxt(UpdatePanel1); BindgrdTrades(); dataobj.Alert("Success", this); } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"UPDATE [dbo].[Ta_Consultation] SET [DateOfConsultation] = @1 ,[Employee_Id] = @2 ,[User_Id] = @3 ,[Type] = @4 ,[PublicRate] = @5 ,[Stage] = @6 ,[Subject] = @7 ,[Notes] = @8 ,[Description] = @9 ,[Answer] = @10 WHERE [Id]=@11"; dataObj.Execute(sql, DateTime.Parse(txtDate.Text).ToShortDateString(), drpEmployee.SelectedItem.Value, drpUser.SelectedItem.Value, txtType.Text, txtTasnif.Text, txtStage.Text, txtSubject.Text, txtNotes.Text, txtDescription.Text, txtAnswer.Text, Request.QueryString["Id"].ToString()); Response.Redirect("Select_Consultation.aspx"); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void LinkAdd_Click(object sender, EventArgs e) { try { addValidationGroup(); if (drpName.SelectedIndex > 0) { string check = @"select * from [dbo].[OrderDetails] where [OrderCode]='" + TxtCode.Text + "' and [Store_Id]='" + drpStore.SelectedItem.Value + "' and [Item_Id]='" + drpName.SelectedItem.Value + "' and [Quantity]=" + float.Parse(txtQuantity.Text) + " and [Type]='" + drpType.Text + "'"; DataTable dt = dataobj.Selectdatatable(check); if (dt.Rows.Count == 0) { string sql = @"INSERT INTO [dbo].[OrderDetails] ([OrderCode],[Item_Id],[Quantity],[Type],[Store_Id]) VALUES(@1,@2,@3,@4,@5)"; dataobj.Execute(sql, TxtCode.Text, drpName.SelectedItem.Value, float.Parse(txtQuantity.Text), drpType.Text, drpStore.SelectedItem.Value); txtBarCode.Text = txtQuantity.Text = string.Empty; drpName.SelectedValue = "اختار الصنف"; drpType.Items.Clear(); } else { dataobj.Alert("تم ادخال هذه البيانات من قبل", this); } } } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"UPDATE [dbo].[Users] SET [Name] = @1,[UserName] = @2,[Mobil] = @3,[Address] = @4 WHERE UserName='******'"; dataobj.Execute(sql, TxtName.Text, txtUserName.Text, txtMobil.Text, txtAddress.Text); string sql1 = @"select Id from [dbo].[Users] where [UserName]='" + txtUserName.Text + "'"; DataTable dt = dataobj.Selectdatatable(sql1); string sql3 = @"delete from Application_Setting where User_Id=@1"; dataobj.Execute(sql3, dt.Rows[0]["Id"].ToString()); for (int i = 0; i < grdSelect.Rows.Count; i++) { CheckBox c = (grdSelect.Rows[i].Cells[0].FindControl("btnCheckAll") as CheckBox); if (c.Checked == true) { string sql2 = @"INSERT INTO [dbo].[Application_Setting] ([User_Id],[Appl_Id],[IsVaild]) VALUES(@1,@2,@3)"; dataobj.Execute(sql2, dt.Rows[0]["Id"].ToString(), grdSelect.Rows[i].Cells[1].Text, true); } } Response.Redirect("Select-Users.aspx"); } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"UPDATE [dbo].[Store] SET [StoreName] =@1,[StoreTel] =@2,[Status] =@3,[Responsibility] =@4,[Mobil] =@5,[StoreAddress] =@6 WHERE [Code]='" + Request.QueryString["code"].ToString() + "'"; databaseaccesslayerobj.Execute(sql, txtARStoreName.Text, txtPhone.Text, chkActive.Checked, txtARManager.Text, txtMobile.Text, txtARAddress.Text); Response.Redirect("Select-Stores.aspx"); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"UPDATE [dbo].[Items] SET [ItemName] = @1,[BarCode] =@2,[Status] =@3,[DateOfItem] =@4,[ItemSaleType] =@5,[ItemPruchType] =@6,[Quantity] = @7 ,[Notes] = @8,[pruchPrice]=@9,[SalePrice]=@10 WHERE [BarCode]='" + Request.QueryString["code"].ToString() + "'"; databaseaccesslayerobj.Execute(sql, TxtName.Text, TxtBarCode.Text, chkActive.Checked, chkDate.Checked, txtSale.Text, txtPruch.Text, float.Parse(txtNum.Text), txtNotes.Text, float.Parse(txtPricePruch.Text), float.Parse(txtPriceSale.Text)); Response.Redirect("Select-Item.aspx"); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void gridSelect_SelectedIndexChanged(object sender, EventArgs e) { try { GridViewRow row = gridSelect.SelectedRow; string sql = @"delete from [dbo].[Ta_Governate] where [GovernateName]=@1"; dataObj.Execute(sql, row.Cells[1].Text); BindgrdTrades(); dataObj.Alert("Success", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int x = 0; if (RadioCustomer.SelectedValue == "مدين") { x = int.Parse(txtMoney.Text); } else { x = int.Parse(txtMoney.Text) * -1; } DateTime dt = DateTime.Parse(txtDate.Text); string d = dt.ToString("MM-dd-yyyy"); string sql = @"INSERT INTO [dbo].[CustomerAndSupplier] ([Code],[Name],[InitialBalance],[DateOfDealing],[Status],[CompanyName],[Responsibility],[Mobil],[Mobil1],[Mobil2],[Customer],[Supplier]) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12)"; databaseaccesslayerobj.Execute(sql, TxtCode.Text, TxtARName.Text, x, d, chkActive.Checked, txtCompanyName.Text, txtResponsibility.Text, txtTelephone.Text, txtTelephone1.Text, txtTelephone2.Text, false, true); databaseaccesslayerobj.Alert("success", this); helper.cleartxt(UpdatePanel1); generateguid(); chkActive.Checked = false; } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int x = 1; if (checkStatus.Checked == true) { x = 0; } string sql = @"INSERT INTO [dbo].[Ta_Task] ([DateOfTask] ,[TaskName] ,[TaskType] ,[DateOfAlert] ,[Notes] ,[Status]) VALUES (@1,@2,@3,@4,@5,@6)"; dataObj.Execute(sql, DateTime.Parse(txtDate.Text).ToShortDateString(), txtName.Text, txtType.Text, DateTime.Parse(txtDateAlert.Text).ToShortDateString(), txtNotes.Text, x); helper.cleartxt(UpdatePanel1); checkStatus.Checked = false; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int x = 0; if (RadioCustomer.SelectedValue == "مدين") { x = int.Parse(txtMoney.Text); } else { x = int.Parse(txtMoney.Text) * -1; } DateTime dt = DateTime.Parse(txtDate.Text); string d = dt.ToString("MM-dd-yyyy"); string sql = @"UPDATE [dbo].[CustomerAndSupplier] SET [Name] = @1,[InitialBalance] = @2,[DateOfDealing] = @3,[Status] = @4, [CompanyName] = @5,[Responsibility] = @6,[Mobil] = @7,[Mobil1] = @8,[Mobil2] = @9 WHERE [Code]=@10"; databaseaccesslayerobj.Execute(sql, TxtARName.Text, x, d, chkActive.Checked, txtCompanyName.Text, txtResponsibility.Text, txtTelephone.Text, txtTelephone1.Text, txtTelephone2.Text, Request.QueryString["code"].ToString()); string sqlsel = @"select * from CustomerAndSupplier where Customer=1 and code='" + Request.QueryString["code"].ToString() + "'"; DataTable dts = databaseaccesslayerobj.Selectdatatable(sqlsel); if (dts.Rows.Count == 1) { Response.Redirect("select-Customer.aspx"); } else if (dts.Rows.Count == 0) { Response.Redirect("select-Supplier.aspx"); } } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (drpGovernate.SelectedIndex > 0) { string sqlcheck = "select * from [dbo].[Ta_LawerPlace] where Name='" + txtName.Text + "' and [Governate_Id]=" + drpGovernate.SelectedItem.Value; DataTable dt = dataObj.Selectdatatable(sqlcheck); if (dt.Rows.Count == 0) { string sql = @"INSERT INTO [dbo].[Ta_LawerPlace] ([Name],[Address],[Telephone],[Governate_Id],[Notes]) VALUES(@1,@2,@3,@4,@5)"; dataObj.Execute(sql, txtName.Text, txtAddress.Text, txtMobil.Text, drpGovernate.SelectedItem.Value, txtStatment.Text); helper.cleartxt(UpdatePanel1); drpGovernate.SelectedIndex = 0; dataObj.Alert("Success", this); } else { dataObj.Alert("هذه البيانات موجودة من قبل", this); } } } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { for (int i = 0; i < grdSelect.Rows.Count; i++) { CheckBox c = (grdSelect.Rows[i].Cells[0].FindControl("btnCheckAll") as CheckBox); if (c.Checked == true) { string checksql = @"select * from ItemStore where ItemCode=(select Code from Items where BarCode='" + grdSelect.Rows[i].Cells[1].Text + "') and StoreCode='" + drpSelect.SelectedItem.Value + "'"; DataTable dt = dataobj.Selectdatatable(checksql); if (dt.Rows.Count == 0) { string selsql = @"select Code from Items where BarCode='" + grdSelect.Rows[i].Cells[1].Text + "'"; DataTable dts = dataobj.Selectdatatable(selsql); string sql = @"INSERT INTO [dbo].[ItemStore] ([ItemCode],[StoreCode]) VALUES(@1,@2)"; dataobj.Execute(sql, dts.Rows[0]["Code"].ToString(), drpSelect.SelectedItem.Value); } } } grdSelect.DataSource = null; grdSelect.DataBind(); drpSelect.Text = "اختار المخزن"; } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void grdSelect_SelectedIndexChanged(object sender, EventArgs e) { try { string sql1 = @"select * from Application_Setting where User_Id=" + Session["Id"] + " and Appl_Id=24 and IsVaild=1"; DataTable dt = DataObj.Selectdatatable(sql1); if (dt.Rows.Count == 1) { GridViewRow row = grdSelect.SelectedRow; string sql = @"DELETE FROM [dbo].[ItemStore] WHERE [StoreCode]='" + drpselect.SelectedItem.Value + "' and [ItemCode]=(select Code from Items where BarCode='" + row.Cells[1].Text + "')"; DataObj.Execute(sql); drpselect.Text = "اختار المخزن"; grdSelect.DataSource = null; grdSelect.DataBind(); } else { Response.Redirect("MainPage.aspx"); } } catch (Exception) { Response.Redirect("MainPage.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Ta_Consultation] ([DateOfConsultation] ,[Employee_Id] ,[User_Id] ,[Type] ,[PublicRate] ,[Stage] ,[Subject] ,[Notes] ,[Description] ,[Answer]) VALUES (@1,@2,@3,@4,@5,@6,@7,@8,@9,@10)"; dataObj.Execute(sql, DateTime.Parse(txtDate.Text).ToShortDateString(), drpEmployee.SelectedItem.Value, drpUser.SelectedItem.Value, txtType.Text, txtTasnif.Text, txtStage.Text, txtSubject.Text, txtNotes.Text, txtDescription.Text, txtAnswer.Text); helper.cleartxt(UpdatePanel1); drpUser.SelectedIndex = drpEmployee.SelectedIndex = 0; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string Expense = @"INSERT INTO [dbo].[ComingMoney] ([Code],[Name],[DateOfComingMoney],[Amount],[User_Id],[Notes]) VALUES(@1,@2,@3,@4,@5,@6)"; databaseaccesslayerobj.Execute(Expense, TxtCode.Text, TxtName.Text, DateTime.Parse(txtDate.Text), float.Parse(txtAmount.Text), Session["Id"], txtNotes.Text); string treasure = @"INSERT INTO [dbo].[TransactionOfTreasure] ([Code],[Amount],[TypeOfOperation],[DateOfOperation],[User_Id]) VALUES(@1,@2,@3,@4,@5)"; databaseaccesslayerobj.Execute(treasure, TxtCode.Text, float.Parse(txtAmount.Text), "ايرادات", DateTime.Now, Session["Id"]); helper.cleartxt(UpdatePanel1); databaseaccesslayerobj.Alert("Success", this); CreateGuid(); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { float x = 0; for (int i = 0; i < grdSelect.Rows.Count; i++) { CheckBox c = (grdSelect.Rows[i].Cells[0].FindControl("btnCheckAll") as CheckBox); if (c.Checked == true) { x = x + float.Parse(grdSelect.Rows[i].Cells[2].Text); string sql3 = @"select * from MonthlyInstallments where CustomerOrSupplier_Id='" + drpName.SelectedItem.Value + "'"; DataTable dts = dataobj.Selectdatatable(sql3); string sql4 = @"update MonthlyInstallmentsDetails set IsVaild=@1 where Date=@2 and Code=@3"; dataobj.Execute(sql4, 1, DateTime.Parse(grdSelect.Rows[i].Cells[1].Text).ToShortDateString(), dts.Rows[0]["Code"].ToString()); } } if (txtAmount.Text != "") { x = x + float.Parse(txtAmount.Text); } string sql1 = @"INSERT INTO [dbo].[TransactionOfTreasure] ([Code],[Amount],[TypeOfOperation],[DateOfOperation],[User_Id]) VALUES(@1,@2,@3,@4,@5)"; dataobj.Execute(sql1, TxtCode.Text, x, "استلام نقدية", DateTime.Now, Session["Id"]); string sql = @"select * from CustomerAndSupplier where Code='" + drpName.SelectedItem.Value + "'"; DataTable dt = dataobj.Selectdatatable(sql); string upsql = @"update CustomerAndSupplier set InitialBalance=InitialBalance+@1 where Code=@2"; dataobj.Execute(upsql, (-1 * x), drpName.SelectedItem.Value); string sql2 = @"INSERT INTO [dbo].[ReciveMoney] ([Code],[CustomerOrSuppler_Id],[DateOfOperation],[Amount]) VALUES(@1,@2,@3,@4)"; dataobj.Execute(sql2, TxtCode.Text, drpName.SelectedItem.Value, DateTime.Parse(txtDate.Text), x); helper.cleartxt(UpdatePanel1); grdSelect.DataSource = null; grdSelect.DataBind(); drpName.Items.Clear(); drpSelect.SelectedValue = "اختار"; CreateGuid(); dataobj.Alert("Success", this); } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void btnUploadImage_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile) { HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { string strs = ViewState["Code"].ToString() + "-" + DateTime.Now.Second + "-" + i + "-" + "0.jpg"; hpf.SaveAs(Server.MapPath(".") + "/IssueFiles/" + strs); string path = "IssueFiles/" + strs.ToString(); string strimge = @"INSERT INTO [dbo].[Ta_IssueFiles] ([Code] ,[Path] ,[Type]) VALUES (@1,@2,@3)"; dataObj.Execute(strimge, ViewState["Code"].ToString(), path, 0); dataObj.Alert("Success", this); } } } } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
public void DeleteOrder(string code, string item, float quantity, string type) { try { string sql = @"delete from OrderDetails where [OrderCode]=@1 and [Item_Id]=(select Code from Items where ItemName=@2) and [Quantity]=@3 and [Type]=@4"; dataobj.Execute(sql, code, item, quantity, type); var list = Key._KeyValuePair("status", "ok"); } catch (Exception ex) { var list = Key._KeyValuePair("status", ex.Message); var json = new JavaScriptSerializer().Serialize(list); Context.Response.Write(json); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Items] ([Code],[ItemName],[BarCode],[Status],[DateOfItem],[ItemSaleType],[ItemPruchType],[Quantity],[Notes],[pruchPrice],[SalePrice]) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11)"; databaseaccesslayerobj.Execute(sql, TxtCode.Text, TxtName.Text, TxtBarCode.Text, chkActive.Checked, chkDate.Checked, txtSale.Text, txtPruch.Text, float.Parse(txtNum.Text), txtNotes.Text, float.Parse(txtPricePruch.Text), float.Parse(txtPriceSale.Text)); databaseaccesslayerobj.Alert("Success", this); helper.cleartxt(UpdatePanel1); CreateGuid(); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Store] ([Code],[StoreName],[StoreTel],[Status],[Responsibility],[Mobil],[StoreAddress]) VALUES(@1,@2,@3,@4,@5,@6,@7)"; databaseaccesslayerobj.Execute(sql, txtStoreNumber.Text, txtARStoreName.Text, txtPhone.Text, chkActive.Checked, txtARManager.Text, txtMobile.Text, txtARAddress.Text); databaseaccesslayerobj.Alert("Success", this); helper.cleartxt(UpdatePanel1); CreateGuid(); } catch (Exception ex) { databaseaccesslayerobj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int x = 0; if (checkStatus.Checked == false) { x = 1; } string check = @"select * from Ta_Sitting where Issue_Id=" + drpIssueNumber.SelectedItem.Value + " and SittingDate='" + DateTime.Parse(txtDate.Text).ToShortDateString() + "'"; DataTable dt = dataObj.Selectdatatable(check); if (dt.Rows.Count == 0) { string sql = @"INSERT INTO [dbo].[Ta_Sitting] ([Issue_Id] ,[HakamName] ,[SittingTime] ,[SittingDate] ,[AlertDate] ,[Notes] ,[Type]) VALUES (@1,@2,@3,@4,@5,@6,@7)"; dataObj.Execute(sql, drpIssueNumber.SelectedItem.Value, txtHakamName.Text, txtTime.Text, DateTime.Parse(txtDate.Text).ToShortDateString(), DateTime.Parse(txtAlertDate.Text).ToShortDateString(), txtNotes.Text, x); helper.cleartxt(UpdatePanel1); drpIssueNumber.SelectedIndex = 0; checkStatus.Checked = false; dataObj.Alert("تم الحفظ بنجاح", this); } else { dataObj.Alert("تم تحديد الجلسة من قبل", this); } } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Ta_MoveIssue] ([Issue_Id] ,[DateOfMove] ,[NumberAppeal] ,[NumberVeto] ,[NumberExecution] ,[Notes]) VALUES (@1,@2,@3,@4,@5,@6)"; dataObj.Execute(sql, drpIssueNumber.SelectedItem.Value, DateTime.Parse(txtDate.Text).ToShortDateString(), txtNumAgain.Text, txtNumGanist.Text, txtNumWork.Text, txtNotes.Text); helper.cleartxt(UpdatePanel1); drpIssueNumber.SelectedIndex = 0; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string sql = @"INSERT INTO [dbo].[Ta_LegalDocument] ([Employee_Id] ,[Number] ,[DocumentType] ,[Details] ,[DocumentNumber] ,[Notes]) VALUES (@1,@2,@3,@4,@5,@6)"; dataObj.Execute(sql, drpEmployee.SelectedItem.Value, txtNumber.Text, drpType.Text, txtDetails.Text, txtDocumentNumber.Text, txtNotes.Text); helper.cleartxt(UpdatePanel1); drpType.SelectedIndex = drpEmployee.SelectedIndex = 0; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int x = 0; if (drpStatus.SelectedIndex == 1) { x = 1; } string sql = @"INSERT INTO [dbo].[Ta_Employee] ([EmployeeName] ,[Adderss] ,[EmployeeType] ,[EmployeeJob] ,[DateOfBirth] ,[Nationality] ,[NationalNumber] ,[Phone] ,[Mobil] ,[Email] ,[AnotherContact] ,[Status] ,[Notes],[Balance]) VALUES (@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14)"; dataObj.Execute(sql, txtName.Text, txtAddress.Text, drpType.Text, txtCareer.Text, DateTime.Parse(txtDate.Text).ToShortDateString(), txtNationality.Text, txtNationalNumber.Text, txtPhone.Text, txtMobil.Text, txtMail.Text, txtAnother.Text, x, txtNotes.Text, 0); helper.cleartxt(UpdatePanel1); drpStatus.SelectedIndex = drpType.SelectedIndex = 0; dataObj.Alert("تم الحفظ بنجاح", this); } catch (Exception ex) { dataObj.Alert(ex.Message, this); } }
protected void LinkAdd_Click(object sender, EventArgs e) { try { addValidationGroup(); if (sumprice() == true) { if (drpName.SelectedIndex > 0) { string check = @"select * from [dbo].[tempPrucheDetails] where [PrucheCode]='" + TxtCode.Text + "' and [Store_Id]='" + drpStore.SelectedItem.Value + "' and [Item_Id]='" + drpName.SelectedItem.Value + "' and [Price]=" + float.Parse(txtprice.Text) + " and [Quantity]=" + float.Parse(txtQuantity.Text) + " and [Type]='" + drpType.Text + "'"; DataTable dt = dataobj.Selectdatatable(check); if (dt.Rows.Count == 0) { float x = float.Parse(ViewState["price"].ToString()); float y = float.Parse(ViewState["quantity"].ToString()); string sql = @"INSERT INTO [dbo].[tempPrucheDetails] ([PrucheCode],[Item_Id],[Quantity],[Type],[Price],[Store_Id]) VALUES(@1,@2,@3,@4,@5,@6)"; dataobj.Execute(sql, TxtCode.Text, drpName.SelectedItem.Value, y, drpType.Text, x, drpStore.SelectedItem.Value); txtBarCode.Text = txtQuantity.Text = txtprice.Text = string.Empty; txtTotal.Text = "0"; drpName.SelectedValue = "اختار الصنف"; drpType.Items.Clear(); sumTotal(); } else { dataobj.Alert("تم ادخال هذه البيانات من قبل", this); } } } } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
private void compeleteOver() { try { string over = @"select * from tempOverSaleCustomer where PrucheCode='" + TxtCode.Text + "'"; DataTable ot = dataobj.Selectdatatable(over); for (int i = 0; i < ot.Rows.Count; i++) { string detail = @"select * from OverSaleDetails where OverCode='" + ot.Rows[i]["Over_Id"].ToString() + "'"; DataTable ox = dataobj.Selectdatatable(detail); for (int j = 0; j < ox.Rows.Count; j++) { string inse = @"INSERT INTO [dbo].[tempPrucheDetails] ([PrucheCode],[Item_Id],[Quantity],[Type],[Store_Id],[OverDis]) VALUES(@1,@2,@3,@4,@5,@6)"; dataobj.Execute(inse, TxtCode.Text, ox.Rows[j]["Item_Id"].ToString(), (float.Parse(ox.Rows[j]["Quantity"].ToString()) * float.Parse(ot.Rows[i]["Quantity"].ToString())), ox.Rows[j]["Type"].ToString(), drpStore.SelectedItem.Value, 1); } } string sqlTran = @"select (select Code from Items where BarCode=i.BarCode) as code,o.Quantity as Num,Price,Type,Date,Store_Id from [dbo].[tempPrucheDetails] o left join Items i on o.Item_Id=i.Code where [PrucheCode]='" + TxtCode.Text + "' and [OverDis]=1"; DataTable dt = dataobj.Selectdatatable(sqlTran); for (int i = 0; i < dt.Rows.Count; i++) { string check = @"select ItemPruchType,ItemSaleType,Quantity from Items where Code='" + dt.Rows[i]["code"].ToString() + "'"; DataTable dts = dataobj.Selectdatatable(check); if (dts.Rows[0]["ItemPruchType"].ToString() == dt.Rows[i]["Type"].ToString()) { string selSame = @"select top(1)Quantity as Quantity from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable ds = dataobj.Selectdatatable(selSame); float x = float.Parse(dt.Rows[i]["Num"].ToString()) * (float.Parse(dts.Rows[0]["Quantity"].ToString())); int y = 1; string newval = ds.Rows[0]["Quantity"].ToString(); for (int j = 0; j < y; j++) { if (x > (float.Parse(newval))) { x = x - float.Parse(ds.Rows[0]["Quantity"].ToString()); string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; dataobj.Execute(up, -100, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); string del = @"delete from TransactionOfStore where Quantity=-100"; dataobj.Execute(del); string selSame1 = @"select top(1)Quantity as Quantity from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable ds1 = dataobj.Selectdatatable(selSame1); newval = ds1.Rows[0]["Quantity"].ToString(); y++; } else if (x == (float.Parse(newval))) { string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; dataobj.Execute(up, -100, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); string del = @"delete from TransactionOfStore where Quantity=-100"; dataobj.Execute(del); } else { string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; float upnum = (float.Parse(newval) - x); dataobj.Execute(up, upnum, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); } } } else if (dts.Rows[0]["ItemSaleType"].ToString() == dt.Rows[i]["Type"].ToString()) { string selSame = @"select top(1)Quantity as Quantity from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable ds = dataobj.Selectdatatable(selSame); float x = float.Parse(dt.Rows[i]["Num"].ToString()); int y = 1; string newval = ds.Rows[0]["Quantity"].ToString(); for (int j = 0; j < y; j++) { if (x > (float.Parse(newval))) { x = x - float.Parse(ds.Rows[0]["Quantity"].ToString()); string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; dataobj.Execute(up, -100, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); string del = @"delete from TransactionOfStore where Quantity=-100"; string selSame1 = @"select top(1)Quantity as Quantity from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; dataobj.Execute(del); DataTable ds1 = dataobj.Selectdatatable(selSame1); newval = ds1.Rows[0]["Quantity"].ToString(); y++; } else if (x == (float.Parse(newval))) { string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; dataobj.Execute(up, -100, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); string del = @"delete from TransactionOfStore where Quantity=-100"; dataobj.Execute(del); } else { string selSameto = @"select top(1)* from TransactionOfStore where Store_Id='" + dt.Rows[i]["Store_Id"].ToString() + "' and ItemId='" + dt.Rows[i]["code"].ToString() + "' order by DateOfItem"; DataTable dm = dataobj.Selectdatatable(selSameto); string up = @"UPDATE [dbo].[TransactionOfStore] SET [Quantity]=@1 where [Code] = @2 and [ItemId] = @3 and [Quantity] = @4 and[TypeOfStore] = @5 and [TypeOfOperation] = @6 and [DateOfItem] = @7 and [Store_Id] = @8"; float upnum = (float.Parse(newval) - x); dataobj.Execute(up, upnum, dm.Rows[0]["Code"].ToString(), dm.Rows[0]["ItemId"].ToString(), dm.Rows[0]["Quantity"].ToString(), dm.Rows[0]["TypeOfStore"].ToString(), dm.Rows[0]["TypeOfOperation"].ToString(), dm.Rows[0]["DateOfItem"].ToString(), dm.Rows[0]["Store_Id"].ToString()); } } } } string sqlTrea = @"INSERT INTO [dbo].[TransactionOfTreasure] ([Code],[Amount],[TypeOfOperation],[DateOfOperation],[User_Id]) VALUES(@1,@2,@3,@4,@5)"; float Amount = float.Parse(txtPay.Text); dataobj.Execute(sqlTrea, TxtCode.Text, Amount, "مبيعات عروض", DateTime.Now.ToString(), Session["Id"]); string sqldel = @"delete from [dbo].[tempPrucheDetails] where [PrucheCode]=@1 and [OverDis]=1"; dataobj.Execute(sqldel, TxtCode.Text); string sql = @"insert into [dbo].[OverSaleCustomer] select * from [dbo].[tempOverSaleCustomer] where PrucheCode=@1"; dataobj.Execute(sql, TxtCode.Text); string sqldel1 = @"delete from [dbo].[tempOverSaleCustomer] where [PrucheCode]=@1"; dataobj.Execute(sqldel1, TxtCode.Text); } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }
protected void LinkAdd_Click(object sender, EventArgs e) { try { if (sumprice() == true) { if (drpName.SelectedIndex > 0) { string check = @"select * from [dbo].[tempPrucheDetails] where [PrucheCode]='" + TxtCode.Text + "' and [Store_Id]='" + drpStore.SelectedItem.Value + "' and [Item_Id]='" + drpName.SelectedItem.Value + "' and [Price]=" + float.Parse(txtprice.Text) + " and [Quantity]=" + float.Parse(txtQuantity.Text) + " and [Type]='" + drpType.Text + "'"; DataTable dt = dataobj.Selectdatatable(check); string checksum = @"select Quantity,Type,Item_Id from [dbo].[tempPrucheDetails] where [PrucheCode]='" + TxtCode.Text + "' and [Item_Id]='" + drpName.SelectedItem.Value + "'"; DataTable dte = dataobj.Selectdatatable(checksum); if (dte.Rows.Count > 0) { string sqlch = @"select sum(Quantity) as sum from [dbo].[TransactionOfStore] where [Store_Id]='" + drpStore.SelectedItem.Value + "' and ItemId=(select Code from Items where BarCode='" + txtBarCode.Text + "')"; DataTable dst = dataobj.Selectdatatable(sqlch); float An = 0; for (int i = 0; i < dte.Rows.Count; i++) { string sal = @"SELECT ItemPruchType,Quantity FROM [dbo].[Items] where [Code]='" + dte.Rows[i]["Item_Id"].ToString() + "'"; DataTable dx = dataobj.Selectdatatable(sal); if (dx.Rows[0]["ItemPruchType"].ToString() == dte.Rows[i]["Type"].ToString()) { An = An + (float.Parse(dte.Rows[i]["Quantity"].ToString()) * float.Parse(dx.Rows[0]["Quantity"].ToString())); } else { An = An + (float.Parse(dte.Rows[i]["Quantity"].ToString())); } } string sals = @"SELECT ItemPruchType,Quantity FROM [dbo].[Items] where [Code]='" + drpName.SelectedItem.Value + "'"; DataTable dxm = dataobj.Selectdatatable(sals); if (dxm.Rows[0]["ItemPruchType"].ToString() == dte.Rows[0]["Type"].ToString()) { An = An + (float.Parse(txtQuantity.Text) * float.Parse(dxm.Rows[0]["Quantity"].ToString())); } else { An = An + float.Parse(txtQuantity.Text); } if (An <= (float.Parse(dst.Rows[0]["sum"].ToString()))) { if (dt.Rows.Count == 0) { ViewState["price"] = float.Parse(txtprice.Text); ViewState["quantity"] = float.Parse(txtQuantity.Text); float x = float.Parse(ViewState["price"].ToString()); float y = float.Parse(ViewState["quantity"].ToString()); string sql = @"INSERT INTO [dbo].[tempPrucheDetails] ([PrucheCode],[Item_Id],[Quantity],[Type],[Price],[Store_Id]) VALUES(@1,@2,@3,@4,@5,@6)"; dataobj.Execute(sql, TxtCode.Text, drpName.SelectedItem.Value, y, drpType.Text, x, drpStore.SelectedItem.Value); txtBarCode.Text = txtQuantity.Text = txtprice.Text = string.Empty; txtTotal.Text = "0"; drpName.SelectedValue = "اختار الصنف"; drpType.Items.Clear(); sumTotal(); txtPay.Text = 0.ToString(); } else { dataobj.Alert("تم ادخال هذه البيانات من قبل", this); } } else { dataobj.Alert("الكمية غير متاحة", this); } } else { if (dt.Rows.Count == 0) { ViewState["price"] = float.Parse(txtprice.Text); ViewState["quantity"] = float.Parse(txtQuantity.Text); float x = float.Parse(ViewState["price"].ToString()); float y = float.Parse(ViewState["quantity"].ToString()); string sql = @"INSERT INTO [dbo].[tempPrucheDetails] ([PrucheCode],[Item_Id],[Quantity],[Type],[Price],[Store_Id]) VALUES(@1,@2,@3,@4,@5,@6)"; dataobj.Execute(sql, TxtCode.Text, drpName.SelectedItem.Value, y, drpType.Text, x, drpStore.SelectedItem.Value); txtBarCode.Text = txtQuantity.Text = txtprice.Text = string.Empty; txtTotal.Text = "0"; drpName.SelectedValue = "اختار الصنف"; drpType.Items.Clear(); sumTotal(); txtPay.Text = 0.ToString(); } else { dataobj.Alert("تم ادخال هذه البيانات من قبل", this); } } } } } catch (Exception ex) { dataobj.Alert(ex.Message, this); } }