コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            BillItemNarrationEL        _BillItemNarrationEL;
            BillItemNarrationDL        _BillItemNarrationDL = new BillItemNarrationDL();
            List <BillItemNarrationEL> lstBillItemNarration = new List <BillItemNarrationEL>();

            try
            {
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    _BillItemNarrationEL = new BillItemNarrationEL();
                    _BillItemNarrationEL.Bill_Item_Id = _BillItemEL.Bill_Item_Id;
                    _BillItemNarrationEL.Narration    = dataGridView1.Rows[i].Cells["Narration"].Value.ToString();

                    if ((dataGridView1.Rows[i].Cells["BillItem_Narration_Id"].Value != null))
                    {
                        _BillItemNarrationEL.BillItem_Narration_Id = Convert.ToInt32(dataGridView1.Rows[i].Cells["BillItem_Narration_Id"].Value);;
                    }
                    else
                    {
                        _BillItemNarrationEL.BillItem_Narration_Id = 0;
                    }
                    lstBillItemNarration.Add(_BillItemNarrationEL);
                }
            }
            catch (Exception)
            {
            }


            SQLHelper      _SQLHelper  = new SQLHelper();
            SqlTransaction transaction = _SQLHelper.BeginTrans();

            try
            {
                for (int i = 0; i < lstBillItemNarration.Count; i++)
                {
                    if (lstBillItemNarration[i].BillItem_Narration_Id == 0)
                    {
                        _BillItemNarrationDL.Insert(transaction, lstBillItemNarration[i]);
                    }
                    else
                    {
                        _BillItemNarrationDL.Update(transaction, lstBillItemNarration[i]);
                    }
                }

                DeletedItemNarration.ForEach(r => _BillItemNarrationDL.Delete(transaction, r));

                transaction.Commit();
                Common.MessageSave();
                GridBind();
            }
            catch (Exception)
            {
                transaction.Rollback();
            }
        }
コード例 #2
0
        void GridBind()
        {
            dataGridView1.Rows.Clear();
            try
            {
                BillItemNarrationDL        _BillItemNarrationDL = new BillItemNarrationDL();
                List <BillItemNarrationEL> lstBillItemNarration = _BillItemNarrationDL.GetBillItemNarrationBy_BillItemId(_BillItemEL.Bill_Item_Id);


                for (int i = 0; i < lstBillItemNarration.Count; i++)
                {
                    int index = dataGridView1.Rows.Add();
                    dataGridView1.Rows[index].Cells["Bill_Item_Id"].Value          = lstBillItemNarration[i].Bill_Item_Id;
                    dataGridView1.Rows[index].Cells["BillItem_Narration_Id"].Value = lstBillItemNarration[i].BillItem_Narration_Id;
                    dataGridView1.Rows[index].Cells["Narration"].Value             = lstBillItemNarration[i].Narration;
                }
            }
            catch
            {
            }
        }
コード例 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 9) // for print
                {
                    BillEL objBillEL = new BillEL();
                    objBillEL.Bill_Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value);

                    BillReportViewer objBillReportViewer = new BillReportViewer(companyEL, objBillEL);
                    objBillReportViewer.ShowDialog();
                    objBillReportViewer.Dispose();
                }
                if (e.ColumnIndex == 10) //For Delete
                {
                    if (Common.MessageConfim("Are You Want To Delete This "))
                    {
                        SQLHelper      objSQLHelper      = new SQLHelper();
                        SqlTransaction objSqlTransaction = objSQLHelper.BeginTrans();

                        BillDL objBillDL = new BillDL();
                        BillEL objBillEL = new BillEL();
                        objBillEL.Bill_Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value);

                        BillDetailDL        objBillDetailDL = new BillDetailDL();
                        List <BillDetailEL> lstBillDetail   = objBillDetailDL.GetBillDetailByBillId(objBillEL.Bill_Id);


                        BillItemDL        objBillItemDL = new BillItemDL();
                        List <BillItemEL> lstBillItemEL = objBillItemDL.GetBillItemByBillId(objBillEL.Bill_Id);

                        BillItemNarrationDL        _BillItemNarrationDL = new BillItemNarrationDL();
                        List <BillItemNarrationEL> lstBillItemNarration = new List <BillItemNarrationEL>();


                        try
                        {
                            lstBillItemEL.ForEach(r => lstBillItemNarration.AddRange(_BillItemNarrationDL.GetBillItemNarrationBy_BillItemId(r.Bill_Item_Id)));


                            lstBillItemNarration.ForEach(n => _BillItemNarrationDL.Delete(objSqlTransaction, n));
                            lstBillDetail.ForEach(r => objBillDetailDL.Delete(objSqlTransaction, r));
                            lstBillItemEL.ForEach(r => objBillItemDL.Delete(objSqlTransaction, r));

                            objBillDL.Delete(objSqlTransaction, objBillEL);

                            objSqlTransaction.Commit();
                            Common.MessageDelete();
                            GridBind();
                        }
                        catch (Exception)
                        {
                            objSqlTransaction.Rollback();
                        }
                    }
                }
                if (e.ColumnIndex == 11)//For bill Edit
                {
                    BillDL _BillDL   = new BillDL();
                    BillEL objBillEL = _BillDL.GetBillById(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value));

                    CreateBill objCreateBill = new CreateBill(companyEL, objBillEL);
                    objCreateBill.ControlBox  = true;
                    objCreateBill.MinimizeBox = false;

                    objCreateBill.ShowDialog();
                    GridBind();
                }
            }
            catch
            {
            }
        }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            {
                BillItemEL        _BillItemEL;
                BillItemDL        _BillItemDL = new BillItemDL();
                List <BillItemEL> lstBillItem = new List <BillItemEL>();
                try
                {
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        _BillItemEL         = new BillItemEL();
                        _BillItemEL.Bill_Id = _BillParentItem.Bill_Id;
                        _BillItemEL.Purchase_Order_Detail_Id = null;
                        _BillItemEL.Form     = Convert.ToDecimal(dataGridView1.Rows[i].Cells["Form"].Value);
                        _BillItemEL.Color    = Convert.ToInt32(dataGridView1.Rows[i].Cells["Color"].Value);
                        _BillItemEL.Rate     = Convert.ToDecimal(dataGridView1.Rows[i].Cells["Rate"].Value);
                        _BillItemEL.Quantity = Convert.ToDouble(dataGridView1.Rows[i].Cells["Quantity"].Value);
                        //_BillItemEL.Item_Name = dataGridView1.Rows[i].Cells["Bill_Item_Name"].Value.ToString();
                        _BillItemEL.Item_Id   = Convert.ToInt32(dataGridView1.Rows[i].Cells["ItemName"].Value);
                        _BillItemEL.Parent_Id = _BillParentItem.Bill_Item_Id;

                        if ((dataGridView1.Rows[i].Cells["Bill_Item_Id"].Value != null))
                        {
                            _BillItemEL.Bill_Item_Id = Convert.ToInt32(dataGridView1.Rows[i].Cells["Bill_Item_Id"].Value);;
                        }
                        else
                        {
                            _BillItemEL.Bill_Item_Id = 0;
                        }
                        lstBillItem.Add(_BillItemEL);
                    }
                }
                catch (Exception)
                {
                }

                SQLHelper      _SQLHelper  = new SQLHelper();
                SqlTransaction transaction = _SQLHelper.BeginTrans();
                try
                {
                    for (int i = 0; i < lstBillItem.Count; i++)
                    {
                        if (lstBillItem[i].Bill_Item_Id == 0)
                        {
                            _BillItemDL.Insert(transaction, lstBillItem[i]);
                        }
                        else
                        {
                            _BillItemDL.Update(transaction, lstBillItem[i]);
                        }
                    }


                    BillItemNarrationDL        _BillItemNarrationDL   = new BillItemNarrationDL();
                    List <BillItemNarrationEL> lstBillItemNarrationEL = new List <BillItemNarrationEL>();

                    DeletedlstBillItem.ForEach(r => lstBillItemNarrationEL.AddRange(_BillItemNarrationDL.GetBillItemNarrationBy_BillItemId(r.Bill_Item_Id)));
                    lstBillItemNarrationEL.ForEach(n => _BillItemNarrationDL.Delete(transaction, n));
                    DeletedlstBillItem.ForEach(r => _BillItemDL.Delete(transaction, r));

                    transaction.Commit();
                    Common.MessageSave();
                    GridBind();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }