Exemple #1
0
        private void Add_Items_Load(object sender, EventArgs e)
        {
            Sale.Database.SalesData salesData = new Sale.Database.SalesData();
            salesData.FnConn();
            DataTable dt = salesData.FillData("currentstock", "", "spsales");

            dt.Columns.Add("status", Type.GetType("System.Boolean"));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["status"] = false;
            }
            if (dt.Rows.Count > 0)
            {
                gridControl1.DataSource = dt;
            }
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                cmbpaymentmode.SelectedIndex = 0;
                DataTable source = gridControl1.DataSource as DataTable;
                source.Clear();
                gridControl1.DataSource = source;
                cmbcustomer.Text        = "";
                txtaddress.Text         = "";
                CustomerId          = "";
                txtphone.Text       = "";
                txtsalesperson.Text = "";
                txtgrosstotal.Text  = "0";
                txtdiscount.Text    = "0";
                txtnettotal.Text    = "0";
                txtpayamount.Text   = "0";
                txtbalance.Text     = "0";
                Test.Sale.Database.SalesData sales = new Sale.Database.SalesData();
                sales.FnConn();
                DataTable dt1 = sales.FillData("M", "", "spsales");

                if (dt1.Rows.Count > 0)
                {
                    int    number    = Convert.ToInt32(dt1.Rows[0]["number"].ToString()) + 1;
                    string invoiceno = number + "";
                    txtinvoice.Text = "INV/" + invoiceno.PadLeft(5, '0');
                }
                sales.FnTrans();
                //cmbpaymentmode.Text = "";
                txtbalancedue.Text     = "0";
                dtppaymentdue.Text     = "";
                barButtonItem1.Enabled = true;
                deliveryno             = "";
            }
            catch (Exception)
            {
            }
        }
Exemple #4
0
        private void cmbcustomer_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbcustomer.Text != "")
            {
                Test.Sale.Database.SalesData sales = new Sale.Database.SalesData();
                sales.FnConn();
                DataTable dt = sales.FillData("search", cmbcustomer.Text, "spCustomer");

                if (dt.Rows.Count > 0)
                {
                    txtaddress.Text = dt.Rows[0]["address"].ToString();
                    txtphone.Text   = dt.Rows[0]["phone"].ToString();
                    CustomerId      = dt.Rows[0]["customerID"].ToString();
                }
                else
                {
                    CustomerId      = "";
                    txtaddress.Text = "";
                    txtphone.Text   = "";
                }
                sales.FnTrans();
            }
        }
        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) { }
        }
Exemple #6
0
 private void gridView1_HiddenEditor(object sender, EventArgs e)
 {
     try
     {
         int slno = gridView1.GetFocusedDataSourceRowIndex();
         Test.Sale.Database.SalesData quatation = new Sale.Database.SalesData();
         System.Data.DataRow          row       = gridView1.GetDataRow(gridView1.FocusedRowHandle);
         row["slno"] = (slno + 1) + "";
         if (gridView1.FocusedColumn.FieldName.Equals("itemCode"))
         {
             String itemcode = row["itemcode"].ToString();
             if (itemcode != "")
             {
                 quatation.FnConn();
                 DataTable dt = quatation.FillData("stock", itemcode, "spsales");
                 if (dt.Rows.Count > 0)
                 {
                     //row["barcode"] = dt.Rows[0]["qrCode"].ToString();
                     row["itemName"]   = dt.Rows[0]["itemName"].ToString();
                     row["brandName"]  = dt.Rows[0]["brandName"].ToString();
                     row["realqty"]    = dt.Rows[0]["currentstock"].ToString();
                     row["category"]   = dt.Rows[0]["category"].ToString();
                     row["damageqty"]  = "0";
                     row["balanceqty"] = "0";
                 }
             }
         }
         if (gridView1.FocusedColumn.FieldName.Equals("itemName"))
         {
             String itemcode = row["itemName"].ToString();
             if (itemcode != "")
             {
                 quatation.FnConn();
                 DataTable dt = quatation.FillData("stockname", itemcode, "spsales");
                 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["realqty"]    = dt.Rows[0]["currentstock"].ToString();
                     row["category"]   = dt.Rows[0]["category"].ToString();
                     row["damageqty"]  = "0";
                     row["balanceqty"] = "0";
                 }
             }
         }
         if (gridView1.FocusedColumn.FieldName.Equals("damageqty"))
         {
             double damageqty = 0, qty = 0;
             try
             {
                 damageqty = Convert.ToDouble(row["damageqty"].ToString());
             }
             catch (Exception ex)
             {
                 row["damageqty"] = "0";
             }
             try
             {
                 qty = Convert.ToDouble(row["realqty"].ToString());
             }
             catch (Exception ex)
             {
                 row["realqty"] = "0";
             }
             double balance = qty - damageqty;
             row["balanceqty"] = balance + "";
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #7
0
        private void Sales_Invoice_Load(object sender, EventArgs e)
        {
            typecash.IsOn = true;
            cmbpaymentmode.SelectedIndex = 0;
            Test.Sale.Database.SalesData sales = new Sale.Database.SalesData();
            sales.FnConn();
            DataTable dt1 = sales.FillData("M", "", "spsales");

            if (dt1.Rows.Count > 0)
            {
                int    number    = Convert.ToInt32(dt1.Rows[0]["number"].ToString()) + 1;
                string invoiceno = number + "";
                txtinvoice.Text = "INV/" + invoiceno.PadLeft(5, '0');
            }
            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) { }
                }
            }
            dtpdate.EditValue = DateTime.Now;
            String    res = sales.FnTrans();
            DataTable dt  = new DataTable();

            dt.Columns.Add("slno", Type.GetType("System.Int32"));
            dt.Columns.Add("invoice_no", 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("offer", Type.GetType("System.Double"));
            dt.Columns.Add("unitPrice", Type.GetType("System.Double"));
            dt.Columns.Add("amount", Type.GetType("System.Double"));
            dt.Columns.Add("discountPercent", Type.GetType("System.Double"));
            dt.Columns.Add("discountAmount", Type.GetType("System.Double"));
            dt.Columns.Add("taxPercent", Type.GetType("System.Double"));
            dt.Columns.Add("taxAmount", Type.GetType("System.Double"));
            dt.Columns.Add("totalAmount", Type.GetType("System.Double"));
            DataRow dr = dt.NewRow();

            dt.Rows.Add(dr);
            gridControl1.DataSource = dt;
            if (deliveryno != null)
            {
                sales.FnConn();
                DataSet ds = sales.FillDataSet("searchgrid", deliveryno, "spsalesDelivery");
                sales.FnTrans();
                DataTable delivery     = ds.Tables[0];
                DataTable deliverygrid = ds.Tables[1];
                if (delivery.Rows.Count > 0)
                {
                    CustomerId       = delivery.Rows[0]["customerid"] + "";
                    cmbcustomer.Text = delivery.Rows[0]["customerName"] + "";
                    txtaddress.Text  = delivery.Rows[0]["address"] + "";
                    // txtphone.Text = delivery.Rows[0]["contact"] + "";
                    txtsalesperson.Text = delivery.Rows[0]["salesPerson"] + "";
                    dt.Clear();
                    sales.FnConn();
                    for (int i = 0; i < deliverygrid.Rows.Count; i++)
                    {
                        string barcode = deliverygrid.Rows[i]["barcode"] + "";
                        double qty     = Convert.ToDouble(deliverygrid.Rows[i]["quantity"] + "");

                        if (barcode != null)
                        {
                            DataTable dts = sales.FillData("barcodedatails", barcode, "spQuatation");
                            if (dts.Rows.Count > 0)
                            {
                                string itemCode    = dts.Rows[0]["productCode"] + "";
                                string description = dts.Rows[0]["itemName"] + "";
                                string brandName   = dts.Rows[0]["brandName"] + "";

                                double unitprice  = Convert.ToDouble(dts.Rows[0]["salesRate1"] + "");
                                double totalprice = unitprice * qty;
                                dt.Rows.Add(i + 1, "", barcode, itemCode, description, brandName, qty, "1", unitprice, totalprice, 0, 0, 0, 0, totalprice);
                            }
                        }
                    }
                    sales.FnTrans();
                    calculateTotal();
                }
            }
        }
Exemple #8
0
        private void gridView1_ShownEditor(object sender, EventArgs e)
        {
            Test.Sale.Database.SalesData sales = new Sale.Database.SalesData();
            if (gridView1.FocusedColumn.FieldName.Equals("barcode"))//Don't work only for this column
            {
                TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit;
                if (currentEditor != null)
                {
                    AutoCompleteStringCollection customSource = new AutoCompleteStringCollection();

                    sales.FnConn();
                    DataTable dt  = sales.FillData("barcode", "", "spQuatation");
                    string    res = sales.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("itemcode"))//Don't work only for this column
            {
                TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit;
                if (currentEditor != null)
                {
                    AutoCompleteStringCollection customSource = new AutoCompleteStringCollection();
                    sales.FnConn();
                    DataTable dt  = sales.FillData("itemcode", "", "spQuatation");
                    string    res = sales.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("description"))//Don't work only for this column
            {
                TextEdit currentEditor = (sender as GridView).ActiveEditor as TextEdit;
                if (currentEditor != null)
                {
                    AutoCompleteStringCollection customSource = new AutoCompleteStringCollection();
                    sales.FnConn();
                    DataTable dt  = sales.FillData("name", "", "spQuatation");
                    string    res = sales.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();
                    sales.FnConn();
                    customSource = null;

                    currentEditor.MaskBox.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
                    currentEditor.MaskBox.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                    currentEditor.MaskBox.AutoCompleteCustomSource = customSource;
                }
            }
        }