Esempio n. 1
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (btnsave.Text == "Update")
            {
                string charges, fedas = "";
                if (rdplus.Checked == true)
                {
                    charges = "+";
                }
                else
                {
                    charges = "-";
                }

                if (rdabsoluteamt.Checked == true)
                {
                    fedas = "0";
                }
                else if (rdonqty.Checked == true)
                {
                    fedas = "1";
                }
                else if (rdper.Checked == true)
                {
                    fedas = "%";
                }
                else if (rdbags.Checked == true)
                {
                    fedas = "2";
                }
                else if (rdonweight.Checked == true)
                {
                    fedas = "3";
                }
                string gst;
                if (chkgst.Checked == true)
                {
                    gst = "1";
                }
                else
                {
                    gst = "0";
                }
                conn.execute("UPDATE [dbo].[BillSundry]SET [BillSundryName] = '" + txtheading.Text + "',[Percentage] = '" + txtcalculate.Text + "',[Symbol] = '" + fedas + "',[BillSundryType] = '" + charges + "',[IE] = 'E',[ApplyOn] = '" + cmbperof.Text + "',[AccountID] = '" + cmbaccount.SelectedValue + "',[AccountName] = '" + cmbaccount.Text + "',[OT1] = '" + cmbcosting.Text + "',[OT2] = '" + txthsn.Text + "',[OT3] = '" + gst + "',[OT4] = '',[OT5] = '',[OT6] = '',[OT7] = '',[OT8] = '',[OT9] = '',[OT10] = '',[ON1] = '" + txtapplyon.Text + "',[isactive]=1 WHERE billsundryid='" + sundryid + "'");
                clearall();
                listviewdatabind();
                btnsave.Text = "Save";
                MessageBox.Show("Update successfully");
                if (flagforbind == 1)
                {
                    // defaultSale.bindperticular();
                    //defaultSaleOrder.bindperticular();
                    try
                    {
                        gSTVouchers.bindperticular();
                    }
                    catch
                    {
                    }
                    try
                    {
                        defaultSale.bindperticular();
                    }
                    catch
                    {
                    }
                    try
                    {
                        defaultSaleOrder.bindperticular();
                    }
                    catch
                    {
                    }
                    try
                    {
                        salePurchaseOrderSimpleformate.bindperticular();
                    }
                    catch
                    {
                    }
                    if (string.IsNullOrEmpty(pvc) == true)
                    {
                        master.RemoveCurrentTab();
                    }
                    else
                    {
                        master.RemoveCurrentTab1(pvc, txtheading.Text);
                    }
                }
                else
                {
                    txtheading.Focus();
                    this.ActiveControl = txtheading;
                }
                txtheading.Text = "";


                //  conn.execute("INSERT INTO [dbo].[BillSundry]([BillSundryName],[Percentage],[Symbol],[BillSundryType],[IE],[ApplyOn],[AccountID],[AccountName],[OT1],[OT2],[OT3],[OT4],[OT5],[OT6],[OT7],[OT8],[OT9],[OT10],[ON1])VALUES(,,,,'E',,,,,'','','','','','','','','',");
            }
            else
            {
                string charges, fedas = "";
                if (rdplus.Checked == true)
                {
                    charges = "+";
                }
                else
                {
                    charges = "-";
                }

                if (rdabsoluteamt.Checked == true)
                {
                    fedas = "0";
                }
                else if (rdonqty.Checked == true)
                {
                    fedas = "1";
                }
                else if (rdper.Checked == true)
                {
                    fedas = "%";
                }
                else if (rdbags.Checked == true)
                {
                    fedas = "2";
                }
                else if (rdonweight.Checked == true)
                {
                    fedas = "3";
                }
                string gst1;
                if (chkgst.Checked == true)
                {
                    gst1 = "1";
                }
                else
                {
                    gst1 = "0";
                }

                if (!string.IsNullOrEmpty(txtheading.Text))
                {
                    conn.execute("INSERT INTO [dbo].[BillSundry]([BillSundryName],[Percentage],[Symbol],[BillSundryType],[IE],[ApplyOn],[AccountID],[AccountName],[OT1],[OT2],[OT3],[OT4],[OT5],[OT6],[OT7],[OT8],[OT9],[OT10],[ON1],[isactive])VALUES('" + txtheading.Text + "','" + txtcalculate.Text + "','" + fedas + "','" + charges + "','E','" + cmbperof.Text + "','" + cmbaccount.SelectedValue + "','" + cmbaccount.Text + "','" + cmbcosting.Text + "','" + txthsn.Text + "','" + gst1 + "','','','','','','','','" + txtapplyon.Text + "','1')");
                    clearall();
                    listviewdatabind();
                    MessageBox.Show("Insert successfully");
                    if (flagforbind == 1)
                    {
                        try
                        {
                            gSTVouchers.bindperticular();
                        }
                        catch
                        {
                        }
                        try
                        {
                            defaultSale.bindperticular();
                        }
                        catch
                        {
                        }
                        try
                        {
                            defaultSaleOrder.bindperticular();
                        }
                        catch
                        {
                        }
                        try
                        {
                            salePurchaseOrderSimpleformate.bindperticular();
                        }
                        catch
                        {
                        }
                        if (string.IsNullOrEmpty(pvc) == true)
                        {
                            master.RemoveCurrentTab();
                        }
                        else
                        {
                            master.RemoveCurrentTab1(pvc, txtheading.Text);
                        }
                    }
                    else
                    {
                        txtheading.Focus();
                        this.ActiveControl = txtheading;
                    }
                    txtheading.Text = "";
                }
                else
                {
                    MessageBox.Show("Charges Head is Required Filed.");
                    return;
                }
            }
        }