private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { cmbcustomer.Text = ""; txtaddress.Text = ""; txtphone.Text = ""; txtnetamount.Text = "0"; DataTable source = gridControl1.DataSource as DataTable; source.Clear(); gridControl1.DataSource = source; Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); quatation.FnConn(); DataTable dt1 = quatation.FillData("M", ""); String res = quatation.FnTrans(); if (dt1.Rows.Count > 0) { int number = Convert.ToInt32(dt1.Rows[0]["number"].ToString()) + 1; string quonum = number + ""; txtquatationnno.Text = "QU/" + quonum.PadLeft(5, '0'); } barButtonItem1.Enabled = true; } catch (Exception) { } }
private void Sales_Quatation_List_Load(object sender, EventArgs e) { Sale.Database.QuatationData quatationData = new Sale.Database.QuatationData(); quatationData.FnConn(); DataTable dt = quatationData.FillData("quo", ""); if (dt.Rows.Count > 0) { gridControl1.DataSource = dt; } }
private void Sales_Quotation_Load(object sender, EventArgs e) { txtnetamount.Text = "0"; Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); quatation.FnConn(); DataTable dt1 = quatation.FillData("M", ""); String res = quatation.FnTrans(); if (dt1.Rows.Count > 0) { int number = Convert.ToInt32(dt1.Rows[0]["number"].ToString()) + 1; string quonum = number + ""; txtquatationnno.Text = "QU/" + quonum.PadLeft(5, '0'); } DataTable dt = new DataTable(); dt.Columns.Add("slno", Type.GetType("System.Int32")); dt.Columns.Add("quotationNo", Type.GetType("System.String")); dt.Columns.Add("barcode", Type.GetType("System.String")); dt.Columns.Add("itemcode", Type.GetType("System.String")); dt.Columns.Add("description", Type.GetType("System.String")); dt.Columns.Add("brandName", Type.GetType("System.String")); dt.Columns.Add("quantity", Type.GetType("System.Double")); dt.Columns.Add("unitPrice", Type.GetType("System.Double")); dt.Columns.Add("totalAmount", Type.GetType("System.Double")); DataRow dr = dt.NewRow(); dt.Rows.Add(dr); gridControl1.DataSource = dt; dtpdate.EditValue = DateTime.Now; Test.Sale.Database.SalesData sales = new Sale.Database.SalesData(); sales.FnConn(); DataTable dt2 = sales.FillData("S", "", "spCustomer"); if (dt2.Rows.Count > 0) { for (int i = 0; i < dt2.Rows.Count; i++) { try { cmbcustomer.Properties.Items.Add(dt2.Rows[i]["name"].ToString()); } catch (Exception ex) { } } } sales.FnTrans(); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { gridView1.RefreshData(); DataTable source = gridControl1.DataSource as DataTable; DataTable dt = new DataTable(); dt.Clear(); dt.Columns.Add("quotationno"); dt.Columns.Add("date"); dt.Columns.Add("id"); dt.Columns.Add("name"); dt.Columns.Add("address"); dt.Columns.Add("phone"); dt.Columns.Add("totalamount"); dt.Rows.Add(new object[] { txtquatationnno.Text, dtpdate.Text, CustomerId, cmbcustomer.Text, txtaddress.Text, txtphone.Text, txtnetamount.Text }); Test.Sale.Database.QuatationData quatationData = new Sale.Database.QuatationData(source, dt); quatationData.FnConn(); quatationData.fnTransactionData(); quatationData.FnTrans(); MessageBox.Show("Quotation creater", "ALERT", MessageBoxButtons.OK, MessageBoxIcon.Information); barButtonItem1.Enabled = false; }
private void gridView1_HiddenEditor(object sender, EventArgs e) { try { int slno = gridView1.GetFocusedDataSourceRowIndex(); Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); System.Data.DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle); row["slno"] = (slno + 1) + ""; row["status"] = "No Invoice"; if (gridView1.FocusedColumn.FieldName.Equals("itemCode")) { String barcode = row["itemCode"].ToString(); if (barcode != "") { quatation.FnConn(); DataTable dt = quatation.FillData("itemcodedatails", barcode); if (dt.Rows.Count > 0) { row["description"] = dt.Rows[0]["itemName"].ToString(); row["unitPrice"] = dt.Rows[0]["salesRate1"].ToString(); row["quantity"] = "0"; } } } if (gridView1.FocusedColumn.FieldName.Equals("description")) { String description = row["description"].ToString(); if (description != "") { quatation.FnConn(); DataTable dt = quatation.FillData("description", description); if (dt.Rows.Count > 0) { row["itemCode"] = dt.Rows[0]["productCode"].ToString(); row["unitPrice"] = dt.Rows[0]["salesRate1"].ToString(); row["quantity"] = "0"; } } } if (gridView1.FocusedColumn.FieldName.Equals("quantity")) { Test.Sale.Database.SalesData salesdata = new Sale.Database.SalesData(); double quantity = 0, unitprice = 0; try { quantity = Convert.ToDouble(row["quantity"] + ""); } catch (Exception ex1) { row["quantity"] = "0"; } string itemCode = row["itemCode"].ToString(); salesdata.FnConn(); DataTable dt = salesdata.FillData("stock", itemCode, "spsales"); if (dt.Rows.Count > 0) { double currentstock = Convert.ToDouble(dt.Rows[0]["currentstock"].ToString()); if (currentstock > quantity) { double rate = 0, qty; try { rate = Convert.ToDouble(row["unitPrice"].ToString()); } catch (Exception ex) { rate = 0; } row["amount"] = (quantity * rate) + ""; int index = gridView1.GetFocusedDataSourceRowIndex(); gridView1.RefreshRow(index); calculateTotal(); gridView1.FocusedColumn = gridView1.GetVisibleColumn(3); gridView1.FocusedRowHandle = index; gridView1.ShowEditor(); } else { MessageBox.Show("Product not in stock . Available quantity " + currentstock, "ALERT", MessageBoxButtons.OK, MessageBoxIcon.Information); row["quantity"] = "0"; } } } } catch (Exception ex) { } }
private void gridView1_ShownEditor(object sender, EventArgs e) { Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); if (gridView1.FocusedColumn.FieldName.Equals("itemCode"))//Don't work only for this column { TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit; if (currentEditor != null) { AutoCompleteStringCollection customSource = new AutoCompleteStringCollection(); quatation.FnConn(); DataTable dt = quatation.FillData("itemcode", ""); string res = quatation.FnTrans(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { customSource.Add(dt.Rows[i][0].ToString()); } } // customSource.Add("Programa 1"); // customSource.Add("Paaaaaaa 3"); //customSource.Add("Pabbbbbb 2"); currentEditor.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; currentEditor.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource; currentEditor.MaskBox.AutoCompleteCustomSource = customSource; } } else if (gridView1.FocusedColumn.FieldName.Equals("description"))//Don't work only for this column { TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit; if (currentEditor != null) { AutoCompleteStringCollection customSource = new AutoCompleteStringCollection(); quatation.FnConn(); DataTable dt = quatation.FillData("name", ""); string res = quatation.FnTrans(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { customSource.Add(dt.Rows[i][0].ToString()); } } currentEditor.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; currentEditor.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource; currentEditor.MaskBox.AutoCompleteCustomSource = customSource; } } else if (gridView1.FocusedColumn.FieldName.Equals("quantity"))//Don't work only for this column { TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit; if (currentEditor != null) { AutoCompleteStringCollection customSource = new AutoCompleteStringCollection(); //quatation.FnConn(); //DataTable dt = quatation.FillData("name", ""); //string res = quatation.FnTrans(); //if (dt.Rows.Count > 0) //{ // for (int i = 0; i < dt.Rows.Count; i++) // { // customSource.Add(dt.Rows[i][0].ToString()); // } //} currentEditor.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; currentEditor.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource; currentEditor.MaskBox.AutoCompleteCustomSource = customSource; } } }
private void gridView1_HiddenEditor(object sender, EventArgs e) { try { int slno = gridView1.GetFocusedDataSourceRowIndex(); Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); System.Data.DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle); row["slno"] = (slno + 1) + ""; if (gridView1.FocusedColumn.FieldName.Equals("quantity")) { double quantity = 0, unitprice = 0; try { quantity = Convert.ToDouble(row["quantity"] + ""); } catch (Exception ex1) { row["quantity"] = "0"; } try { unitprice = Convert.ToDouble(row["unitprice"] + ""); } catch (Exception invalidstring) { row["unitprice"] = "0"; } double total = quantity * unitprice; row["totalamount"] = total + ""; int index = gridView1.GetFocusedDataSourceRowIndex(); gridView1.RefreshRow(index); calculateTotal(); // DevExpress.XtraGrid.GridControl gc = (DevExpress.XtraGrid.GridControl)sender; //DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gc.KeyboardFocusView; //gv.FocusedColumn = gv.GetVisibleColumn(5); //gv.FocusedRowHandle = index; //gv.ShowEditor(); gridView1.FocusedColumn = gridView1.GetVisibleColumn(6); gridView1.FocusedRowHandle = index; gridView1.ShowEditor(); } else if (gridView1.FocusedColumn.FieldName.Equals("unitPrice")) { // System.Data.DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle); double quantity = 0, unitprice = 0; try { quantity = Convert.ToDouble(row["quantity"] + ""); } catch (Exception ex1) { row["quantity"] = "0"; } try { unitprice = Convert.ToDouble(row["unitprice"] + ""); } catch (Exception invalidstring) { row["unitprice"] = "0"; } double total = quantity * unitprice; row["totalamount"] = total + ""; int index = gridView1.GetFocusedDataSourceRowIndex(); gridView1.RefreshRow(index); calculateTotal(); } if (gridView1.FocusedColumn.FieldName.Equals("barcode")) { String barcode = row["barcode"].ToString(); if (barcode != "") { quatation.FnConn(); DataTable dt = quatation.FillData("barcodedatails", barcode); if (dt.Rows.Count > 0) { row["itemcode"] = dt.Rows[0]["productCode"].ToString(); row["description"] = dt.Rows[0]["itemName"].ToString(); row["brandName"] = dt.Rows[0]["brandName"].ToString(); row["quantity"] = "0"; row["unitPrice"] = dt.Rows[0]["salesRate1"].ToString(); row["totalAmount"] = "0"; } } } if (gridView1.FocusedColumn.FieldName.Equals("itemcode")) { String itemcode = row["itemcode"].ToString(); if (itemcode != "") { quatation.FnConn(); DataTable dt = quatation.FillData("itemcodedatails", itemcode); if (dt.Rows.Count > 0) { row["barcode"] = dt.Rows[0]["qrCode"].ToString(); row["description"] = dt.Rows[0]["itemName"].ToString(); row["brandName"] = dt.Rows[0]["brandName"].ToString(); row["quantity"] = "0"; row["unitPrice"] = dt.Rows[0]["salesRate1"].ToString(); row["totalAmount"] = "0"; } } } if (gridView1.FocusedColumn.FieldName.Equals("description")) { String description = row["description"].ToString(); if (description != "") { quatation.FnConn(); DataTable dt = quatation.FillData("description", description); if (dt.Rows.Count > 0) { row["barcode"] = dt.Rows[0]["qrCode"].ToString(); row["itemcode"] = dt.Rows[0]["productCode"].ToString(); row["brandName"] = dt.Rows[0]["brandName"].ToString(); row["quantity"] = "0"; row["unitPrice"] = dt.Rows[0]["salesRate1"].ToString(); row["totalAmount"] = "0"; } } } } catch (Exception ex) { } }
private void gridView1_HiddenEditor(object sender, EventArgs e) { try { int slno = gridView1.GetFocusedDataSourceRowIndex(); Test.Sale.Database.QuatationData quatation = new Sale.Database.QuatationData(); System.Data.DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle); // row["slno"] = (slno + 1) + ""; if (gridView1.FocusedColumn.FieldName.Equals("retqty")) { double quantity = 0, unitprice = 0, retqty = 0; try { quantity = Convert.ToDouble(row["quantity"] + ""); } catch (Exception ex1) { row["quantity"] = "0"; } try { retqty = Convert.ToDouble(row["retqty"] + ""); } catch (Exception ex1) { row["retqty"] = "0"; } try { unitprice = Convert.ToDouble(row["unitprize"] + ""); } catch (Exception invalidstring) { row["unitprize"] = "0"; } if (retqty > quantity) { row["retqty"] = "0"; retqty = 0; MessageBox.Show("Return quantity is greater than purchased quantity", "ALERT", MessageBoxButtons.OK, MessageBoxIcon.Error); } double total = (quantity - retqty) * unitprice; row["amount"] = total + ""; row["totalamount"] = total + ""; int index = gridView1.GetFocusedDataSourceRowIndex(); gridView1.RefreshRow(index); calculateTotal(); // DevExpress.XtraGrid.GridControl gc = (DevExpress.XtraGrid.GridControl)sender; //DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gc.KeyboardFocusView; //gv.FocusedColumn = gv.GetVisibleColumn(5); //gv.FocusedRowHandle = index; //gv.ShowEditor(); gridView1.FocusedColumn = gridView1.GetVisibleColumn(6); gridView1.FocusedRowHandle = index; gridView1.ShowEditor(); } } catch (Exception) { } }