private void btnSupplier_Click(object sender, EventArgs e) { //try //{ // if (string.IsNullOrEmpty(txtSupName.Text.Trim()) || string.IsNullOrEmpty(txtSupPhone.Text.Trim())) // { // FrmMessage.Show("Fields with * Symbols are Mandatory!!!", caption, OkButton, ErrorIcon); // } // else // { // if (btnSupplier.Text == "Add") // { // if (int.Parse(sqlhelp.ExecuteScalar("select Count(*) from Supplier where SupplierName='" + txtSupName.Text.Trim() + "'")) != 0) // { // FrmMessage.Show("Supplier Already Exists"); // } // else // { // bool result = sqlhelp.ExecuteNonQuery("insert into Supplier (SupplierName,SupplierPhone,Address,CreatedBy) values " + // "('" + txtSupName.Text.Trim() + "','" + txtSupPhone.Text.Trim() + "','" + txtaddress.Text.Trim() + "'," + GlobalData.UserID + ")"); // if (result == true) // { // FrmMessage.Show("Supplier Added successfully"); // btnClearSup_Click(sender, e); // } // } // } // else // { // if (int.Parse(sqlhelp.ExecuteScalar("select Count(*) from Supplier where SupplierName='" + txtSupName.Text.Trim() + "' and SupplierID <> " + SupplierID + " ")) != 0) // { // FrmMessage.Show("Supplier Already Exists"); // } // else // { // bool result = sqlhelp.ExecuteNonQuery("Update Supplier set SupplierName='" + txtSupName.Text.Trim() + "'," + // "SupplierPhone='" + txtSupPhone.Text.Trim() + "',Address='" + txtaddress.Text.Trim() + "',CreatedBy=" + GlobalData.UserID + "" + // " where SupplierID=" + SupplierID + ""); // if (result == true) // { // FrmMessage.Show("Supplier Updated successfully"); // btnTbAdd_Click(sender, e); // } // } // } // } //} //catch (Exception ex) //{ //} try { if (string.IsNullOrEmpty(txtSupName.Text.Trim()) || string.IsNullOrEmpty(txtSupPhone.Text.Trim())) { FrmMessage.Show("Fields with * Symbols are Mandatory!!!", caption, OkButton, ErrorIcon); } else { if (btnSupplier.Text == "Add") { if (int.Parse(sqlhelp.ExecuteScalar("select Count(*) from Supplier where SupplierName='" + txtSupName.Text.Trim() + "'")) != 0) { FrmMessage.Show("Supplier Already Exists"); } else { bool result = sqlhelp.ExecuteNonQuery("insert into Supplier (SupplierName,SupplierPhone,Address,CreatedBy,SupplierType,ContactPerson,ContactPersonPhone,City,State,Email,CSTRegNo,APGSTNo,TINNo,Remarks,BankName,AccNo,BankCode) values " + "('" + txtSupName.Text.Trim() + "','" + txtSupPhone.Text.Trim() + "','" + txtaddress.Text.Trim() + "'," + GlobalData.UserID + ",'" + cmbSTKcategories.Text.Trim() + "','" + textBox1.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + textBox8.Text.Trim() + "','" + textBox9.Text.Trim() + "','" + textBox10.Text.Trim() + "','" + textBox11.Text.Trim() + "','" + textBox12.Text.Trim() + "','" + textBox13.Text.Trim() + "')"); if (result == true) { FrmMessage.Show("Supplier Added successfully"); btnClearSup_Click(sender, e); } } } else { if (int.Parse(sqlhelp.ExecuteScalar("select Count(*) from Supplier where SupplierName='" + txtSupName.Text.Trim() + "' and SupplierID <> " + SupplierID + " ")) != 0) { FrmMessage.Show("Supplier Already Exists"); } else { bool result = sqlhelp.ExecuteNonQuery("Update Supplier set SupplierName='" + txtSupName.Text.Trim() + "'," + "SupplierPhone='" + txtSupPhone.Text.Trim() + "',Address='" + txtaddress.Text.Trim() + "',CreatedBy=" + GlobalData.UserID + ",SupplierType='" + cmbSTKcategories.Text.Trim() + "',ContactPerson='" + textBox1.Text.Trim() + "',ContactPersonPhone='" + textBox3.Text.Trim() + "',City='" + textBox5.Text.Trim() + "',State='" + textBox6.Text.Trim() + "',Email='" + textBox4.Text.Trim() + "',CSTRegNo='" + textBox7.Text.Trim() + "',APGSTNo='" + textBox8.Text.Trim() + "',TINNo='" + textBox9.Text.Trim() + "',Remarks='" + textBox10.Text.Trim() + "',BankName='" + textBox11.Text.Trim() + "',AccNo='" + textBox12.Text.Trim() + "',BankCode='" + textBox13.Text.Trim() + "'" + " where SupplierID=" + SupplierID + ""); if (result == true) { FrmMessage.Show("Supplier Updated successfully"); btnTbAdd_Click(sender, e); SearchGroup.Visible = true; AddGroup.Visible = false; } } } } } catch (Exception ex) { } }
private void btnSearch_Click(object sender, EventArgs e) { string BillNo; string Status; if (string.IsNullOrEmpty(txtTransactionNo.Text)) { BillNo = "%"; } else { BillNo = txtTransactionNo.Text; } if (string.IsNullOrEmpty(ddlSrchStatus.Text) || ddlSrchStatus.Text == "All") { Status = "%"; } else { Status = ddlSrchStatus.Text; } try { sqlhelper = new SQLHelper(); statusGrid.DataSource = null; statusGrid.Columns.Clear(); ds = new DataSet(); ds = sqlhelper.ExecuteQueries("select TransactionNo as [Bill No],CustName as [Customer Name],Phone,DeliveryDate as [Delivery Date],Status,EmpID from workStatus where TransactionNo like '" + BillNo + "' and Status like'" + Status + "'"); if (ds.Tables[0].Rows.Count > 0) { statusGrid.DataSource = ds.Tables[0]; DataGridViewComboBoxColumn ddlStatus = new DataGridViewComboBoxColumn(); statusGrid.Columns.Remove("Status"); // Remove original ddlStatus.HeaderText = "Status"; ddlStatus.MaxDropDownItems = 3; ddlStatus.Items.Add("Pending"); ddlStatus.Items.Add("Working"); ddlStatus.Items.Add("Completed"); //ddlStatus.DataSource = ds.Tables[0]; //ddlStatus.DisplayMember = "Status"; ddlStatus.Width = 140; // Hide drop-down arrow until selected ddlStatus.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // Allow sorting... ddlStatus.SortMode = DataGridViewColumnSortMode.Automatic; // Add ColumnDepartment onto DataGridView layout statusGrid.Columns.Add(ddlStatus); ds1 = new DataSet(); ds1 = sqlhelper.ExecuteQueries("select UserID,Name from Users"); if (ds1.Tables[0].Rows.Count > 0) { DataRow dr = ds1.Tables[0].NewRow(); dr["Name"] = "Select"; dr["UserID"] = 0; ds1.Tables[0].Rows.InsertAt(dr, 0); DataGridViewComboBoxColumn ddlEmp = new DataGridViewComboBoxColumn(); statusGrid.Columns.Remove("EmpID"); // Remove original ddlEmp.HeaderText = "Employee"; ddlEmp.DataSource = ds1.Tables[0]; ddlEmp.DisplayMember = "Name"; ddlEmp.ValueMember = "UserID"; ddlEmp.Width = 140; // Hide drop-down arrow until selected ddlEmp.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // Allow sorting... ddlEmp.SortMode = DataGridViewColumnSortMode.Automatic; // Add ColumnDepartment onto DataGridView layout statusGrid.Columns.Add(ddlEmp); DataGridViewButtonColumn btnUpdate = new DataGridViewButtonColumn(); btnUpdate.HeaderText = "Update"; btnUpdate.Text = "Update"; btnUpdate.UseColumnTextForButtonValue = true; btnUpdate.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; btnUpdate.FlatStyle = FlatStyle.Standard; btnUpdate.CellTemplate.Style.BackColor = Color.Honeydew; statusGrid.Columns.Add(btnUpdate); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { statusGrid.Rows[i].Cells[4].Value = ds.Tables[0].Rows[i]["Status"].ToString(); if (string.IsNullOrEmpty(ds.Tables[0].Rows[i]["EmpID"].ToString())) { statusGrid.Rows[i].Cells[5].Value = int.Parse(ds1.Tables[0].Rows[0]["UserID"].ToString()); } else { statusGrid.Rows[i].Cells[5].Value = int.Parse(ds.Tables[0].Rows[i]["EmpID"].ToString()); } } foreach (DataGridViewColumn dc in statusGrid.Columns) { if (dc.Index.Equals(4) || dc.Index.Equals(5)) { dc.ReadOnly = false; } else { dc.ReadOnly = true; } } } else { FrmMessage.Show("Employees are not Found. Please Insert Employees First"); } } else { FrmMessage.Show("No Records Found"); } } catch (Exception ex) { } }
private void savesmartPos() { try { if (string.IsNullOrEmpty(txtSAmount.Text) || dataGridView4.Rows.Count <= 0) { FrmMessage.Show("You cannot Generate Bill without Items"); } else { sqlhelper = new SQLHelper(); bool result; DataSet ds = new DataSet(); int count; ds = sqlhelper.ExecuteQueries("select TranNo from TransactionNo"); if (ds.Tables[0].Rows.Count > 0) { if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TranNo"].ToString())) { count = 1; } else { count = int.Parse(ds.Tables[0].Rows[0]["TranNo"].ToString()) + 1; } } else { count = 1; } string todaysDate = sqlhelper.ExecuteScalar("select format(date(),'ddmmyyyy')"); trnNo = todaysDate + count; result = sqlhelper.ExecuteNonQuery("insert into Payment(TransactionNo,TotalAmount,DiscountAmount,BillPaid,CreatedBy)" + "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "'," + "" + GlobalData.UserID + ")"); result = sqlhelper.ExecuteNonQuery("insert into TaxHistory(TransactionNo,TotalAmount,DiscountAmount,BillPaid,VATAmount,Paid,CreatedBy)" + "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', '" + SVatAmt.Text + "', '" + SDue.Text + "'," + "" + GlobalData.UserID + ")"); if (result == true) { //string InitCode = ""; //int lengthofInitCode = 0; //string MaxCode; string PaymentId = sqlhelper.ExecuteScalar("select max(PaymentID) from Payment"); for (int i = 0; i < dataGridView4.Rows.Count - 1; i++) { //InitCode = sqlhelper.ExecuteScalar("select CategoryInitCode from Categories where CategoryID=" + dataGridView1.Rows[i].Cells[5].Value.ToString() + ""); //lengthofInitCode = InitCode.Split('-')[0].Length + 1; //MaxCode = sqlhelper.ExecuteScalar("SELECT Max(val(Mid([CodeNo]," + (lengthofInitCode + 1) + "))) as MaxCode FROM Transactions where CategoryID =" + dataGridView1.Rows[i].Cells[5].Value.ToString() + ""); //if (string.IsNullOrEmpty(MaxCode)) //{ // MaxCode = InitCode.Split('-')[1]; //} //InitCode = InitCode.Split('-')[0] + "-"; //MaxCode = InitCode + (int.Parse(MaxCode) + 1).ToString(); result = sqlhelper.ExecuteNonQuery("insert into Transactions(PaymentID,Barcode,CategoryID,ItemID,SaleQty,VatPercent,ItemPrice,CreatedBy)" + "values (" + PaymentId + ",'" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'," + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + "," + "" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + "," + "" + dataGridView4.Rows[i].Cells["Vat(%)"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Price"].Value.ToString() + "," + GlobalData.UserID + ")"); result = sqlhelper.ExecuteNonQuery("Update Stock Set StockQuantity = (StockQuantity - " + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + ")" + " where CategoryID= " + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + " and " + "ItemID=" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + " and Barcode='" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'"); } if (result == true) { if (checkBox8.Checked == true) { if (string.IsNullOrEmpty(textBox64.Text)) { } else { result = sqlhelper.ExecuteNonQuery("insert into DEALERCREDIT(DealerID,TransactionNo,TotalAmount,DiscountAmount,AfterDiscount,VATAmount,TOTALDUE,CreatedBy,STATUS)" + "values ('" + DEALERID + "','" + trnNo + "','" + txtSTotal.Text + "', '" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', " + SVatAmt.Text + ", " + SDue.Text + ", " + GlobalData.UserID + ", 'CREDIT')"); checkBox8.Checked = false; panel24.Visible = false; textBox62.Text = string.Empty; textBox63.Text = string.Empty; textBox64.Text = string.Empty; } } if (checkBox7.Checked == true) { if (string.IsNullOrEmpty(textBox61.Text)) { } else { result = sqlhelper.ExecuteNonQuery("insert into AGENTEARNEDCOMISSION(ANO,TransactionNo,COMISSIONEARNED,COMISSION)" + "values ('" + ANO + "','" + trnNo + "','" + textBox58.Text + "', '" + textBox59.Text + "')"); checkBox7.Checked = false; panel23.Visible = false; textBox58.Text = string.Empty; textBox59.Text = string.Empty; textBox60.Text = string.Empty; textBox61.Text = string.Empty; } } BillPrintPreview.Document = printDocument3; BillPrintPreview.PrintPreviewControl.Zoom = 1; BillPrintPreview.ShowDialog(); // BillPrint.Print(); } } FrmMessage.Show("Transaction Successful"); Frm_POS form = new Frm_POS { MdiParent = this.MdiParent, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; form.Show(); //cancelSmarttrans(); //textBox12.Text = string.Empty; //textBox13.Text = string.Empty; //textBox14.Text = string.Empty; //textBox15.Text = string.Empty; //SVatAmt.Text = "0"; ////textBox16.Text = "0"; //textBox18.Text = "0"; //txtSTotal.Text = "0"; //textBox19.Text = "PACNO"; //txtSAmount.Text = "0"; //button10.Visible = true; //button8.Visible = false; } } catch (Exception ex) { FrmMessage.Show(ex.ToString()); } }
private void savesmartPos1() { try { if (string.IsNullOrEmpty(txtSAmount.Text) || dataGridView4.Rows.Count <= 0) { FrmMessage.Show("You cannot Generate Bill without Items"); } else if (string.IsNullOrEmpty(textBox12.Text) || string.IsNullOrEmpty(textBox19.Text)) { FrmMessage.Show("Redeem Card No should be Entered or Cancel the Redeem"); } else { sqlhelper = new SQLHelper(); bool result; //result = sqlhelper.ExecuteNonQuery("insert into Customers(CustName,Phone) values ('" + txtCustName.Text + "'," + txtCustPhnNo.Text + ")"); //if (result == true) //{ DataSet ds = new DataSet(); int count; ds = sqlhelper.ExecuteQueries("select TranNo from TransactionNo"); if (ds.Tables[0].Rows.Count > 0) { if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TranNo"].ToString())) { count = 1; } else { count = int.Parse(ds.Tables[0].Rows[0]["TranNo"].ToString()) + 1; } } else { count = 1; } string todaysDate = sqlhelper.ExecuteScalar("select format(date(),'ddmmyyyy')"); trnNo = todaysDate + count; result = sqlhelper.ExecuteNonQuery("insert into Payment(TransactionNo,TotalAmount,DiscountAmount,BillPaid,CreatedBy)" + "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "'," + "" + GlobalData.UserID + ")"); result = sqlhelper.ExecuteNonQuery("insert into TaxHistory(TransactionNo,TotalAmount,DiscountAmount,BillPaid,VATAmount,Paid,CreatedBy)" + "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "','" + SVatAmt.Text + "', '" + SDue.Text + "'," + "" + GlobalData.UserID + ")"); if (result == true) { string PaymentId = sqlhelper.ExecuteScalar("select max(PaymentID) from Payment"); for (int i = 0; i < dataGridView4.Rows.Count; i++) { result = sqlhelper.ExecuteNonQuery("insert into Transactions(PaymentID,Barcode,CategoryID,ItemID,SaleQty,VatPercent,ItemPrice,CreatedBy)" + "values (" + PaymentId + ",'" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'," + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + "," + "" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + "," + "" + dataGridView4.Rows[i].Cells["Vat(%)"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Price"].Value.ToString() + "," + GlobalData.UserID + ")"); result = sqlhelper.ExecuteNonQuery("Update Stock Set StockQuantity = (StockQuantity - " + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + ")" + " where CategoryID= " + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + " and " + "ItemID=" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + " and Barcode='" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'"); } result = sqlhelper.ExecuteNonQuery("insert into RewardPoints(Points, PACNO)" + "values (" + textBox15.Text + "," + textBox19.Text + ")"); if (redeemclick == true) { result = sqlhelper.ExecuteNonQuery("insert into RewardPointsUsed(TransactionNo, PACNO, POINTSUSED)" + "values (" + trnNo + "," + textBox19.Text + "," + textBox18.Text + ")"); result = sqlhelper.ExecuteNonQuery("insert into RewardPoints(Points, PACNO)" + "values (" + "-" + textBox18.Text + "," + textBox19.Text + ")"); } if (result == true) { if (checkBox8.Checked == true) { if (string.IsNullOrEmpty(textBox64.Text)) { } else { result = sqlhelper.ExecuteNonQuery("insert into DEALERCREDIT(DealerID,TransactionNo,TotalAmount,DiscountAmount,AfterDiscount,VATAmount,TOTALDUE,CreatedBy,STATUS)" + "values ('" + DEALERID + "','" + trnNo + "','" + txtSTotal.Text + "', '" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', " + SVatAmt.Text + ", " + SDue.Text + ", " + GlobalData.UserID + ", 'CREDIT')"); checkBox8.Checked = false; panel24.Visible = false; textBox62.Text = string.Empty; textBox63.Text = string.Empty; textBox64.Text = string.Empty; } } if (checkBox7.Checked == true) { if (string.IsNullOrEmpty(textBox61.Text)) { } else { result = sqlhelper.ExecuteNonQuery("insert into AGENTEARNEDCOMISSION(ANO,TransactionNo,COMISSIONEARNED,COMISSION)" + "values ('" + ANO + "','" + trnNo + "','" + textBox58.Text + "', '" + textBox59.Text + "')"); checkBox7.Checked = false; panel23.Visible = false; textBox58.Text = string.Empty; textBox59.Text = string.Empty; textBox60.Text = string.Empty; textBox61.Text = string.Empty; } } BillPrintPreview.Document = printDocument3; BillPrintPreview.PrintPreviewControl.Zoom = 1; BillPrintPreview.ShowDialog(); // BillPrint.Print(); } } FrmMessage.Show("Transaction Successful"); Frm_POS form = new Frm_POS { MdiParent = this.MdiParent, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; form.Show(); } } catch (Exception ex) { FrmMessage.Show(ex.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { bool result; if (string.IsNullOrEmpty(txtAddr.Text.Trim()) || string.IsNullOrEmpty(txtEmpName.Text.Trim()) || string.IsNullOrEmpty(txtLoginId.Text.Trim()) || string.IsNullOrEmpty(txtMobile.Text.Trim()) || ddlRole.SelectedValue.ToString() == "0") { FrmMessage.Show("Fields with * Symbols are Mandatory !!!"); } else { if (btnSave.Text == "Add") { if (string.IsNullOrEmpty(txtPwd.Text) || string.IsNullOrEmpty(txtRePwd.Text)) { FrmMessage.Show("Fields with * Symbols are Mandatory !!!"); } else { if (lblmsg.Visible == true) { } else { int count = int.Parse(sqlhelp.ExecuteScalar("select count(*) from Users where LoginID = '" + txtLoginId.Text.Trim() + "'")); if (count == 0) { status = true; result = sqlhelp.ExecuteNonQuery("INSERT INTO Users([RoleID],[Name],[Address],[Email],[Mobile]," + "[LoginID],[Password],[CreatedBy],[IsActive]) Values (" + ddlRole.SelectedValue + ",'" + txtEmpName.Text + "'" + ",'" + txtAddr.Text + "','" + txtEmail.Text + "','" + txtMobile.Text + "','" + txtLoginId.Text + "'," + " '" + txtPwd.Text + "', " + GlobalData.UserID + "," + status + ")"); if (result == true) { FrmMessage.Show(" Transaction Completed Successfully !!", caption, OkButton, InformationIcon); ClearTextboxes(); } else { FrmMessage.Show("Transaction Unsuccessful.", caption, OkButton, ErrorIcon); } } else { FrmMessage.Show("This LoginID is already in use !!!", caption, OkButton, ErrorIcon); } } } } else { result = sqlhelp.ExecuteNonQuery("UPDATE Users SET RoleID=" + ddlRole.SelectedValue + "," + "Name='" + txtEmpName.Text + "',Address='" + txtAddr.Text + "',Email='" + txtEmail.Text + "'," + "Mobile='" + txtMobile.Text + "' where UserID=" + EmpId + ""); if (result == true) { FrmMessage.Show(" Transaction Completed Successfully !!", caption, OkButton, InformationIcon); btnTbAdd_Click(sender, e); } else { FrmMessage.Show("Transaction Unsuccessful", caption, OkButton, ErrorIcon); } } } }
private void btnSearch_Click(object sender, EventArgs e) { try { if (GlobalData.ReportName == "StockPurchase1") { string ddlcategory = ""; if (ddlcatname.Text == string.Empty) { FrmMessage.Show("No Records Found"); } else { if (ddlcatname.SelectedIndex == 0) { ddlcategory = "%"; } else { ddlcategory = ddlcatname.SelectedValue.ToString(); } } dsr = new DataSetReports(); da = new OleDbDataAdapter("select * from SupplierOrder where SupplierId Like '" + ddlcategory + "' and Cdate(Format(InvoiceDate,'dd-MMM-yy')) Between cdate(format('" + ddlFromDate.Text + "','dd-MMM-yy')) and cdate(format('" + ddlToDate.Text + "','dd-MMM-yy')) ", sqlhelp.Con); da.Fill(dsr.Tables["StockPurchaseRpt"]); if (dsr.Tables["StockPurchaseRpt"].Rows.Count > 0) { reportViewer1.LocalReport.ReportEmbeddedResource = "Inventory.StockPurchase.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("StockPurchaseRpt", dsr.Tables["StockPurchaseRpt"])); reportViewer1.DocumentMapCollapsed = true; reportViewer1.RefreshReport(); } else { reportViewer1.LocalReport.DataSources.Clear(); FrmMessage.Show("No Records Found"); } } else if (GlobalData.ReportName == "SupplierReturn") { string ddlcategory = ""; if (ddlcatname.Text == string.Empty) { FrmMessage.Show("No Records Found"); } else { if (ddlcatname.SelectedIndex == 0) { ddlcategory = "%"; } else { ddlcategory = ddlcatname.SelectedValue.ToString(); } } dsr = new DataSetReports(); da = new OleDbDataAdapter("select * from ReturnItemsToSupplier where SupplierId Like '" + ddlcategory + "' and Cdate(Format(CreatedDate,'dd-MMM-yy')) Between cdate(format('" + ddlFromDate.Text + "','dd-MMM-yy')) and cdate(format('" + ddlToDate.Text + "','dd-MMM-yy')) ", sqlhelp.Con); da.Fill(dsr.Tables["SupplierReturn"]); if (dsr.Tables["SupplierReturn"].Rows.Count > 0) { reportViewer1.LocalReport.ReportEmbeddedResource = "Inventory.SupplierReturn.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SupplierReturn", dsr.Tables["SupplierReturn"])); reportViewer1.DocumentMapCollapsed = true; reportViewer1.RefreshReport(); } else { reportViewer1.LocalReport.DataSources.Clear(); FrmMessage.Show("No Records Found"); } } else if (GlobalData.ReportName == "SupplierPayment") { string ddlcategory = ""; if (ddlcatname.Text == string.Empty) { FrmMessage.Show("No Records Found"); } else { if (ddlcatname.SelectedIndex == 0) { ddlcategory = "%"; } else { ddlcategory = ddlcatname.SelectedValue.ToString(); } } dsr = new DataSetReports(); da = new OleDbDataAdapter("select * from SupplierOrderQ where SupplierId Like '" + ddlcategory + "' and Cdate(Format(InvoiceDate,'dd-MMM-yy')) Between cdate(format('" + ddlFromDate.Text + "','dd-MMM-yy')) and cdate(format('" + ddlToDate.Text + "','dd-MMM-yy')) ", sqlhelp.Con); da.Fill(dsr.Tables["SupplierPayment"]); da1 = new OleDbDataAdapter("select * from SPaidAmount where SupplierId Like '" + ddlcategory + "'", sqlhelp.Con); da1.Fill(dsr.Tables["SupplierPayment1"]); if (dsr.Tables["SupplierPayment"].Rows.Count > 0 || dsr.Tables["SupplierPayment1"].Rows.Count > 0) { reportViewer1.LocalReport.ReportEmbeddedResource = "Inventory.SupplierPayment.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SupplierPayment", dsr.Tables["SupplierPayment"])); reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SupplierPayment1", dsr.Tables["SupplierPayment1"])); reportViewer1.DocumentMapCollapsed = true; reportViewer1.RefreshReport(); } else { reportViewer1.LocalReport.DataSources.Clear(); FrmMessage.Show("No Records Found"); } } } catch (Exception ex) { } }
private void btnPay_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtBillpaid.Text) || dataGridView1.Rows.Count <= 0) { FrmMessage.Show("Please select atleast one service to generate a bill"); } //else if (string.IsNullOrEmpty(txtCustMobile.Text.Trim()) || string.IsNullOrEmpty(txtName.Text.Trim())) //{ // FrmMessage.Show("Please enter the Customer Name and Mobile"); //} else { sqlhelp = new SQLHelper(); bool result = false; //if (Int32.Parse(sqlhelp.ExecuteScalar("select count(Phone) from Customers where Phone='" + txtCustMobile.Text + "'")) == 0) //{ // result = sqlhelp.ExecuteNonQuery("insert into Customers (CustName,Phone) values('" + txtName.Text.Trim() + "','" + txtCustMobile.Text.Trim() + "')"); // CustID = sqlhelp.ExecuteScalar("select max(CustID) from Customers"); //} //else //{ // result = true; //} //if (result == true) //{ result = sqlhelp.ExecuteNonQuery("insert into ServiceTransactions(TotalAmount,DiscountPercent,BillPaid,CreatedBy)" + "values (" + txtGrandTotal.Text + "," + txtDiscount.Text.Trim() + ", " + txtBillpaid.Text + "," + "" + GlobalData.UserID + ")"); if (result == true) { TransID = sqlhelp.ExecuteScalar("select max(STransID) from ServiceTransactions"); for (int i = 0; i < dataGridView1.Rows.Count; i++) { // decimal Commission = 0; decimal ServiceAmount = 0; ServiceAmount = (Math.Round((decimal.Parse(dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString()) - (decimal.Parse(dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString()) * (decimal.Parse(txtDiscount.Text) / 100))), 2)); // Commission = (Math.Round(((ServiceAmount * (decimal.Parse(Int32.Parse(sqlhelp.ExecuteScalar("select COMMISSION from employees where ISACTIVE=True and EMPID=" + dataGridView1.Rows[i].Cells["EMPID"].Value.ToString() + "")).ToString()) / 100))), 2)); result = sqlhelp.ExecuteNonQuery("insert into STransDetails(STransID,ServiceID,ServiceCharge,DiscountPercent)" + "values (" + TransID + "," + dataGridView1.Rows[i].Cells["ServiceID"].Value.ToString() + "," + dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString() + "," + "" + txtDiscount.Text + ")"); } if (result == true) { BillPrintPreview.Document = BillPrint; BillPrintPreview.PrintPreviewControl.Zoom = 1; BillPrintPreview.ShowDialog(); } } FrmMessage.Show("Transaction Successful"); FRM_SERVICEACCOUNT form = new FRM_SERVICEACCOUNT { MdiParent = this.MdiParent, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; form.Show(); //} } } catch (Exception ex) { } finally { } }