コード例 #1
0
ファイル: frmMaster.cs プロジェクト: faspisoft/ColdstoreNew
 private void frmMaster_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         this.Close();
         this.Dispose();
     }
     else if (e.Control && e.KeyCode == Keys.R)
     {
         LoadData(gstr, gstr);
     }
     else if (e.Control && e.KeyCode == Keys.C)
     {
         if (gstr == "Account")
         {
             frm_Account frm = new frm_Account();
             frm.LoadData("0", "Account");
             frm.MdiParent = this.MdiParent;
             frm.Show();
         }
         else if (gstr == "Item")
         {
             frm_Item frm = new frm_Item();
             frm.LoadData("0", "Item");
             frm.MdiParent = this.MdiParent;
             frm.Show();
         }
         else if (gstr == "Inward")
         {
             frm_voucher frm = new frm_voucher();
             frm.LoadData("Inward", "0", "Inward");
             frm.MdiParent = this.MdiParent;;
             frm.Show();
         }
         else if (gstr == "LoanM")
         {
             frm_Loanvou frm = new frm_Loanvou();
             frm.LoadData("LoanMemo", "0", "LoanMemo");
             frm.MdiParent = this.MdiParent;;
             frm.Show();
         }
         else if (gstr == "LoanS")
         {
             frm_Loanvou frm = new frm_Loanvou();
             frm.LoadData("LoanSettlement", "0", "LoanSettlement");
             frm.MdiParent = this.MdiParent;;
             frm.Show();
         }
         else if (gstr == "Outward")
         {
             frm_voucher frm = new frm_voucher();
             frm.LoadData("Outward", "0", "Outward");
             frm.MdiParent = this.MdiParent;;
             frm.Show();
         }
         else if (gstr == "OpeningStock")
         {
             frm_voucher frm = new frm_voucher();
             frm.LoadData("OpeningStock", "0", "Opening Stock");
             frm.MdiParent = this.MdiParent;;
             frm.Show();
         }
     }
 }
コード例 #2
0
ファイル: frmMaster.cs プロジェクト: faspisoft/ColdstoreNew
        private void ansGridView5_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (gstr == "Account")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["Ac_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    frm_Account frm = new frm_Account();
                    frm.LoadData(ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["Ac_id"].Value.ToString(), "Edit Account");
                    frm.MdiParent = this.MdiParent;
                    frm.Show();
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    if (validate(ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["ac_id"].Value.ToString()) == true)
                    {
                        DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                        if (res == DialogResult.OK)
                        {
                            DataTable dtDelete = new DataTable("tblAccount");
                            Database.GetSqlData("select * from tblAccount where Ac_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["Ac_id"].Value, dtDelete);
                            dtDelete.Rows[0].Delete();
                            Database.SaveData(dtDelete);
                            MessageBox.Show("Deleted successfully");
                            LoadData(gstr, "Inward");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Account can not be Deleted,Used in Voucher");
                    }
                    //LoadData(gstr, "Account");
                }
            }



            if (gstr == "Item")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["item_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int grp_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["Item_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_Item frm = new frm_Item();
                        frm.LoadData(grp_id.ToString(), "Edit Product Group");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    if (validate(ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["Item_id"].Value.ToString()) == true)
                    {
                        DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                        if (res == DialogResult.OK)
                        {
                            DataTable dtDelete = new DataTable("tblIteminfo");
                            Database.GetSqlData("select * from tblIteminfo where item_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["item_id"].Value, dtDelete);
                            dtDelete.Rows[0].Delete();
                            Database.SaveData(dtDelete);
                            MessageBox.Show("Deleted successfully");
                            LoadData(gstr, "Product Group");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Item can not be Deleted,Item Used in Voucher");
                    }
                    //LoadData(gstr, "Product Group");
                }
            }
            if (gstr == "Inward")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["vi_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_voucher frm = new frm_voucher();
                        frm.LoadData("Inward", vi_id.ToString(), "Edit Inward");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                    if (res == DialogResult.OK)
                    {
                        int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());


                        if (validate(vi_id.ToString()) == true)
                        {
                            try
                            {
                                Database.BeginTran();


                                DataTable dtDelete = new DataTable("tblvoucherinfo");
                                Database.GetSqlData("select * from tblvoucherinfo where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                                if (dtDelete.Rows.Count > 0)
                                {
                                    dtDelete.Rows[0].Delete();
                                    Database.SaveData(dtDelete);
                                }

                                DataTable dtDelete1 = new DataTable("tblvoucherDet");
                                Database.GetSqlData("select * from tblvoucherdet where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete1);
                                for (int i = 0; i < dtDelete1.Rows.Count; i++)
                                {
                                    dtDelete1.Rows[i].Delete();
                                }
                                Database.SaveData(dtDelete1);
                                dtDelete1 = new DataTable("tblstock");
                                Database.GetSqlData("select * from tblstock where vid=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete1);
                                for (int i = 0; i < dtDelete1.Rows.Count; i++)
                                {
                                    dtDelete1.Rows[i].Delete();
                                }

                                Database.SaveData(dtDelete1);

                                MessageBox.Show("Deleted successfully");
                                Database.CommitTran();
                            }

                            catch (Exception ex)
                            {
                                Database.RollbackTran();
                            }
                            LoadData(gstr, "Inward");
                        }
                    }
                }
            }
            if (gstr == "Outward")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["vi_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_voucher frm = new frm_voucher();
                        frm.LoadData("Outward", vi_id.ToString(), "Edit Outward");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                    if (res == DialogResult.OK)
                    {
                        try
                        {
                            Database.BeginTran();

                            DataTable dtDelete = new DataTable("tblvoucherinfo");
                            Database.GetSqlData("select * from tblvoucherinfo where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);

                            if (dtDelete.Rows.Count > 0)
                            {
                                dtDelete.Rows[0].Delete();
                                Database.SaveData(dtDelete);
                            }

                            dtDelete = new DataTable("tblvoucherDet");
                            Database.GetSqlData("select * from tblvoucherdet where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                            for (int i = 0; i < dtDelete.Rows.Count; i++)
                            {
                                dtDelete.Rows[i].Delete();
                            }
                            Database.SaveData(dtDelete);

                            dtDelete = new DataTable("tblstock");
                            Database.GetSqlData("select * from tblstock where vid=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                            for (int i = 0; i < dtDelete.Rows.Count; i++)
                            {
                                dtDelete.Rows[i].Delete();
                            }
                            Database.SaveData(dtDelete);

                            MessageBox.Show("Deleted successfully");
                            Database.CommitTran();
                        }
                        catch (Exception ex)
                        {
                            Database.RollbackTran();
                        }
                        LoadData(gstr, "Outward");
                    }
                }
            }
            else if (gstr == "LoanM")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["vi_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_Loanvou frm = new frm_Loanvou();
                        frm.LoadData("LoanMemo", vi_id.ToString(), "Edit LoanMemo");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                    if (res == DialogResult.OK)
                    {
                        int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());


                        if (validate(vi_id.ToString()) == true)
                        {
                            try
                            {
                                Database.BeginTran();


                                DataTable dtDelete = new DataTable("tblvoucherinfo");
                                Database.GetSqlData("select * from tblvoucherinfo where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                                if (dtDelete.Rows.Count > 0)
                                {
                                    dtDelete.Rows[0].Delete();
                                    Database.SaveData(dtDelete);
                                }



                                MessageBox.Show("Deleted successfully");
                                Database.CommitTran();
                            }

                            catch (Exception ex)
                            {
                                Database.RollbackTran();
                            }
                            LoadData(gstr, "Loan Advisor");
                        }
                    }
                }
            }
            else if (gstr == "LoanS")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["vi_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_Loanvou frm = new frm_Loanvou();
                        frm.LoadData("LoanSettlement", vi_id.ToString(), "Edit LoanSettlement");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                    if (res == DialogResult.OK)
                    {
                        int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());


                        if (validate(vi_id.ToString()) == true)
                        {
                            try
                            {
                                Database.BeginTran();


                                DataTable dtDelete = new DataTable("tblvoucherinfo");
                                Database.GetSqlData("select * from tblvoucherinfo where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                                if (dtDelete.Rows.Count > 0)
                                {
                                    dtDelete.Rows[0].Delete();
                                    Database.SaveData(dtDelete);
                                }



                                MessageBox.Show("Deleted successfully");
                                Database.CommitTran();
                            }

                            catch (Exception ex)
                            {
                                Database.RollbackTran();
                            }
                            LoadData(gstr, "LoanSettlement");
                        }
                    }
                }
            }
            else if (gstr == "OpeningStock")
            {
                if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                {
                    if (ansGridView5.Rows[ansGridView5.CurrentRow.Index].Cells["vi_id"].Value.ToString() == "0")
                    {
                        return;
                    }
                    int vi_id = int.Parse(ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value.ToString());
                    if (ansGridView5.CurrentCell.OwningColumn.Name == "Edit")
                    {
                        frm_voucher frm = new frm_voucher();
                        frm.LoadData("OpeningStock", vi_id.ToString(), "Edit Opening Stock");
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
                else if (ansGridView5.CurrentCell.OwningColumn.Name == "Delete")
                {
                    DialogResult res = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);
                    if (res == DialogResult.OK)
                    {
                        DataTable dtDelete = new DataTable("tblvoucherinfo");
                        Database.GetSqlData("select * from tblvoucherinfo where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                        if (dtDelete.Rows.Count > 0)
                        {
                            dtDelete.Rows[0].Delete();
                            Database.SaveData(dtDelete);
                        }

                        dtDelete = new DataTable("tblvoucherDet");
                        Database.GetSqlData("select * from tblvoucherdet where vi_id=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                        for (int i = 0; i < dtDelete.Rows.Count; i++)
                        {
                            dtDelete.Rows[i].Delete();
                        }
                        Database.SaveData(dtDelete);

                        dtDelete = new DataTable("tblstock");
                        Database.GetSqlData("select * from tblstock where vid=" + ansGridView5.Rows[ansGridView5.SelectedCells[0].RowIndex].Cells["vi_id"].Value, dtDelete);
                        for (int i = 0; i < dtDelete.Rows.Count; i++)
                        {
                            dtDelete.Rows[i].Delete();
                        }
                        Database.SaveData(dtDelete);

                        MessageBox.Show("Deleted successfully");
                        LoadData(gstr, "Opening Stock");
                    }
                }
            }
        }
コード例 #3
0
ファイル: frmMaster.cs プロジェクト: faspisoft/ColdstoreNew
        void btn_Click(object sender, EventArgs e)
        {
            Button tbtn = (Button)sender;
            string name = tbtn.Name.ToString();

            if (name == "add")
            {
                if (gstr == "Account")
                {
                    frm_Account frm = new frm_Account();
                    frm.LoadData("0", "frm_account");
                    frm.MdiParent = this.MdiParent;
                    frm.Show();
                }
                else if (gstr == "Item")
                {
                    frm_Item frm = new frm_Item();
                    frm.LoadData("0", "Product Group");
                    frm.MdiParent = this.MdiParent;
                    frm.Show();
                }
                else if (gstr == "Inward")
                {
                    frm_voucher frm = new frm_voucher();
                    frm.LoadData("Inward", "0", "Inward");
                    frm.MdiParent = this.MdiParent;;
                    frm.Show();
                }
                else if (gstr == "Outward")
                {
                    frm_voucher frm = new frm_voucher();
                    frm.LoadData("Outward", "0", "Outward");
                    frm.MdiParent = this.MdiParent;;
                    frm.Show();
                }
                else if (gstr == "OpeningStock")
                {
                    frm_voucher frm = new frm_voucher();
                    frm.LoadData("OpeningStock", "0", "Opening Stock");
                    frm.MdiParent = this.MdiParent;;
                    frm.Show();
                }
                else if (gstr == "LoanM")
                {
                    frm_Loanvou frm = new frm_Loanvou();
                    frm.LoadData("LoanMemo", "0", "LoanMemo");
                    frm.MdiParent = this.MdiParent;;
                    frm.Show();
                }
                else if (gstr == "LoanS")
                {
                    frm_Loanvou frm = new frm_Loanvou();
                    frm.LoadData("LoanSettlement", "0", "LoanSettlement");
                    frm.MdiParent = this.MdiParent;;
                    frm.Show();
                }
            }


            else if (name == "refresh")
            {
                LoadData(gstr, gstr);
            }


            else if (name == "quit")
            {
                this.Close();
                this.Dispose();
            }
        }