예제 #1
0
        public void RSearch()
        {
            DateTime dateTime_From = Convert.ToDateTime(dtp_ReturnDateFrom.Value);
            DateTime dateTime_To   = Convert.ToDateTime(dtp_ReturnDateTo.Value.Date.AddHours(23.9));
            String   product_Code  = txt_RProductCode.Text;
            Int32    Customer_Id   = 0;

            try
            {
                Customer_Id = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
            }
            catch (Exception ex)
            {
                Customer_Id = 0;
            }

            BLLCustomerReturn obj_BLLCustomerReturn = new BLLCustomerReturn();

            DataTable dt_CustomerReturn;

            dt_CustomerReturn = obj_BLLCustomerReturn.LoadCustomerReturnForAllDataByReturnDateAndCustomerIDAndProductCode(dateTime_From, dateTime_To, product_Code, Customer_Id);

            dgv_RResult.DataSource = dt_CustomerReturn;

            NumberingTableForDataGridView(dt_CustomerReturn);

            this.dt_CustomerReturn = dt_CustomerReturn;

            RFormatDataGridView();
        }
        private void BindDataGridView()
        {
            DECustomerReturn customerReturnDetail = new DECustomerReturn();
            //customerReturnDetail.ReturnDate = Convert.ToDateTime(dtp_ReturnDate.Text);

            DateTime dateTime_From = Convert.ToDateTime(dtp_ReturnDate.Text);
            DateTime dateTime_To   = Convert.ToDateTime(dtp_ReturnDate.Text).AddHours(23.9);

            try
            {
                customerReturnDetail.Customer_Id = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
            }
            catch (Exception ex)
            {
                return;
            }

            BLLCustomerReturn obj_BLLCustomerReturnDetail = new BLLCustomerReturn();

            DataTable dt_CustomerReturnDetail;

            dt_CustomerReturnDetail = obj_BLLCustomerReturnDetail.LoadCustomerReturnDetailTableForAllDataByReturn(dateTime_From, dateTime_To, customerReturnDetail);

            dgv_ProductList.DataSource = dt_CustomerReturnDetail;

            NumberingTableForDataGridView(dt_CustomerReturnDetail);

            this.dt_ProductList = dt_CustomerReturnDetail;

            FormatDataGridView();

            calculateTotal(dt_CustomerReturnDetail);
        }
        private void save()
        {
            invoiceReturnDetail.CustomerReturn_Id = Guid.NewGuid();
            invoiceReturnDetail.Customer_Id       = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
            invoiceReturnDetail.ReturnDate        = Convert.ToDateTime(dtp_ReturnDate.Value);
            invoiceReturnDetail.Product_Id        = Convert.ToInt32(cbx_Product.SelectedItem.Col3);

            if (rdo_isCarton.Checked == true)
            {
                invoiceReturnDetail.isCarton = true;
            }
            else
            {
                invoiceReturnDetail.isCarton = false;
            }

            invoiceReturnDetail.Qty          = Convert.ToInt32(txt_Quantity.Text);
            invoiceReturnDetail.Price        = Convert.ToDecimal(txt_Rate.Text);
            invoiceReturnDetail.Amount       = Convert.ToDecimal(txt_Amount.Text);
            invoiceReturnDetail.ModifiedDate = Convert.ToDateTime(lbl_Date.Text + " " + lbl_Time.Text);

            BLLCustomerReturn obj_BLLInvoiceReturnDetail = new BLLCustomerReturn();

            try
            {
                int int_Result = obj_BLLInvoiceReturnDetail.InsertData(invoiceReturnDetail);

                if (int_Result > 0)
                {
                    BindDataGridView();
                    clearProductDetail();

                    if (stockIn != null)
                    {
                        stockIn.RSearch();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                invoiceReturnDetail        = new DECustomerReturn();
                obj_BLLInvoiceReturnDetail = null;
                cbx_Product.Focus();
            }
        }
        private void delete()
        {
            invoiceReturnDetail.CustomerReturn_Id = new Guid(dgv_ProductList.CurrentRow.Cells[1].Value.ToString());
            invoiceReturnDetail.Product_Id        = Convert.ToInt32(dgv_ProductList.CurrentRow.Cells[4].Value.ToString());

            if (dgv_ProductList.CurrentRow.Cells[8].Value.ToString().Equals("Cartons"))
            {
                invoiceReturnDetail.isCarton = true;
            }
            else
            {
                invoiceReturnDetail.isCarton = false;
            }

            invoiceReturnDetail.Qty    = Convert.ToInt32(dgv_ProductList.CurrentRow.Cells[7].Value.ToString());
            invoiceReturnDetail.Price  = Convert.ToDecimal(dgv_ProductList.CurrentRow.Cells[9].Value.ToString());
            invoiceReturnDetail.Amount = Convert.ToDecimal(dgv_ProductList.CurrentRow.Cells[10].Value.ToString());

            BLLCustomerReturn obj_BLLCustomerReturn = new BLLCustomerReturn();

            try
            {
                int int_Result = obj_BLLCustomerReturn.DeleteData(invoiceReturnDetail);

                if (int_Result > 0)
                {
                    BindDataGridView();
                    clearProductDetail();

                    if (stockIn != null)
                    {
                        stockIn.RSearch();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                invoiceReturnDetail   = new DECustomerReturn();
                obj_BLLCustomerReturn = null;
                cbx_Product.Focus();
            }
        }