コード例 #1
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (dgv_Customer.CurrentRow != null)
            {
                DialogResult Colse_Result;
                Colse_Result = MessageBox.Show(" Are you sure you want to Delete ?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Colse_Result == DialogResult.Yes)
                {
                    DECustomer customer = new DECustomer();
                    customer.Customer_Id = Convert.ToInt32(dgv_Customer.CurrentRow.Cells[1].Value);
                    customer.Active      = false;

                    BLLCustomer obj_BLLCustomer = new BLLCustomer();

                    int int_Result = obj_BLLCustomer.UpdateCustomerOnlyActiveByCustomerId(customer);

                    if (int_Result > 0)
                    {
                        //MessageBox.Show("Delete Successfully");
                        BindDataGridView();
                    }

                    obj_BLLCustomer = null;
                    customer        = null;
                }
            }
        }
コード例 #2
0
        private void BindDataGridView()
        {
            DECustomer customer = new DECustomer();

            BLLCustomer obj_BLLCustomer = new BLLCustomer();

            DataTable dt_Customer;

            if (txt_FilteredCustomerDescription.Text.Trim().Length <= 0)
            {
                dt_Customer = obj_BLLCustomer.LoadCustomerTableForAllData();
            }
            else
            {
                customer.Customer_Description = txt_FilteredCustomerDescription.Text;
                dt_Customer = obj_BLLCustomer.LoadCustomerTableForAllDataByCustomerDescription(customer);
            }

            dgv_Customer.DataSource = dt_Customer;

            this.dt_Customer = dt_Customer;

            NumberingTableForDataGridView(dt_Customer);

            FormatDataGridView();
        }
コード例 #3
0
        private void save()
        {
            DECustomer customer = new DECustomer();

            AssignData(customer);

            BLLCustomer obj_BLLCustomer = new BLLCustomer();

            try
            {
                int int_Result = obj_BLLCustomer.InsertData(customer);

                if (int_Result > 0)
                {
                    MessageBox.Show(UIConstantMessage.Const_strSaveSuccessfully);
                    BindDataGridView();
                    clearScreen();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                customer        = null;
                obj_BLLCustomer = null;
            }
        }
コード例 #4
0
 private void DisplayData(DECustomer customer)
 {
     txt_CustomerDescription.Tag  = customer.Customer_Id;
     txt_CustomerDescription.Text = customer.Customer_Description;
     txt_Address.Text             = customer.Address;
     txt_PhoneNo.Text             = customer.Phone;
     cbx_Catagory.SelectedValue   = customer.Catagory_Id.ToString();
 }
コード例 #5
0
        private void bindReturnReport(DECustomer customer, DataTable dt_Return)
        {
            rptv_CustomerSaleReport.Clear();
            rptv_CustomerSaleReport.Reset();

            rptv_CustomerSaleReport.ProcessingMode = ProcessingMode.Local;

            LocalReport localReport = rptv_CustomerSaleReport.LocalReport;

            localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_CustomerReturnRpt.rdlc";

            ReportDataSource ds_CustomerSaleSummary = new ReportDataSource();

            ds_CustomerSaleSummary.Name  = "DS_CustomerSaleReturnRpt_dt_CustomerReturn";
            ds_CustomerSaleSummary.Value = dt_Return;

            ReportParameter parDateFrom = new ReportParameter();

            parDateFrom.Name = "parDateFrom";

            ReportParameter parDateTo = new ReportParameter();

            parDateTo.Name = "parDateTo";

            ReportParameter parCustomer = new ReportParameter();

            parCustomer.Name = "parCustomer";

            ReportParameter parAddress = new ReportParameter();

            parAddress.Name = "parAddress";

            ReportParameter parPhone = new ReportParameter();

            parPhone.Name = "parPhone";

            parDateFrom.Values.Add(dtp_InvoiceDateFrom.Value.Date.ToString());
            parDateTo.Values.Add(dtp_InvoiceDateTo.Value.Date.ToString());

            if (rdo_Customer.Checked)
            {
                parCustomer.Values.Add(customer.Customer_Description);
                parAddress.Values.Add(customer.Address);
                parPhone.Values.Add(customer.Phone);
            }
            else
            {
                parCustomer.Values.Add(customer.Catagory_Description);
                parAddress.Values.Add("");
                parPhone.Values.Add("");
            }

            rptv_CustomerSaleReport.LocalReport.SetParameters(new ReportParameter[] { parDateFrom, parDateTo, parCustomer, parAddress, parPhone });

            localReport.DataSources.Add(ds_CustomerSaleSummary);

            rptv_CustomerSaleReport.RefreshReport();
        }
コード例 #6
0
        public int UpdateCustomerOnlyActiveByCustomerId(DECustomer customer)
        {
            DALCustomer obj_DALCustomer = new DALCustomer();

            int int_Result = obj_DALCustomer.UpdateCustomerOnlyActiveByCustomerId(customer);

            obj_DALCustomer = null;

            return(int_Result);
        }
コード例 #7
0
        public DataTable LoadCustomerTableForAllDataByCustomerDescription(DECustomer customer)
        {
            DALCustomer obj_DALCustomer = new DALCustomer();

            DataTable dt_Customer = obj_DALCustomer.LoadCustomerTableForAllDataByCustomerDescription(customer);

            obj_DALCustomer = null;

            return(dt_Customer);
        }
コード例 #8
0
        public int DeleteData(DECustomer customer)
        {
            DALCustomer obj_DALCustomer = new DALCustomer();

            int int_Result = obj_DALCustomer.DeleteData(customer);

            obj_DALCustomer = null;

            return(int_Result);
        }
コード例 #9
0
        public Boolean LoadCustomerRow(DECustomer customer)
        {
            DALCustomer obj_DALCustomer = new DALCustomer();

            Boolean bool_HasRows = obj_DALCustomer.LoadCustomerRow(customer);

            obj_DALCustomer = null;

            return(bool_HasRows);
        }
コード例 #10
0
        private SqlCommand DeclareSqlCmdParameter(SqlCommand SqlCmd, DECustomer customer)
        {
            SqlCmd.Parameters.AddWithValue("@Customer_Id", customer.Customer_Id);
            SqlCmd.Parameters.AddWithValue("@Customer_Description", customer.Customer_Description);
            SqlCmd.Parameters.AddWithValue("@Address", customer.Address);
            SqlCmd.Parameters.AddWithValue("@Phone", customer.Phone);
            SqlCmd.Parameters.AddWithValue("@Catagory_Id", customer.Catagory_Id);
            SqlCmd.Parameters.AddWithValue("@Active", customer.Active);
            SqlCmd.Parameters.AddWithValue("@ModifiedBy", customer.ModifiedBy);
            SqlCmd.Parameters.AddWithValue("@ModifiedDate", customer.ModifiedDate);

            return(SqlCmd);
        }
コード例 #11
0
        public int InsertData(DECustomer customer)
        {
            int int_Result;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "SELECT @Customer_Id = ISNULL(MAX(Customer_Id),0)+1 FROM tbl_Customer INSERT  tbl_Customer  VALUES(@Customer_Id,@Customer_Description,@Address,@Phone,@Active,@ModifiedBy,@ModifiedDate,@Catagory_Id)";

            DeclareSqlCmdParameter(sqlCmd, customer);

            int_Result = SqlConjunction.GetSQLVoid(sqlCmd);

            sqlCmd = null;

            return(int_Result);
        }
コード例 #12
0
        public DataTable LoadCustomerTableForAllDataByCustomerDescription(DECustomer customer)
        {
            DataTable dt_Customer;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "SELECT 0 As 'No',Cus.Customer_Id,Cus.Customer_Description,Cus.Address,Cus.Phone,Cus.Catagory_Id,Cat.Catagory_Description, Cus.Active,Cus.ModifiedBy,Cus.ModifiedDate FROM tbl_Customer Cus LEFT JOIN tbl_CustomerCatagory Cat on Cus.Catagory_Id = Cat.Catagory_Id where Cus.Active = 'true' And	Cus.Customer_Description  LIKE '%' + @Customer_Description+ '%' order by Cus.Customer_Description";

            sqlCmd = DeclareSqlCmdParameter(sqlCmd, customer);

            dt_Customer = SqlConjunction.GetSQLDataTable(sqlCmd);

            sqlCmd = null;

            return(dt_Customer);
        }
コード例 #13
0
        public int UpdateCustomerOnlyActiveByCustomerId(DECustomer customer)
        {
            int int_Result;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "UPDATE tbl_Customer SET Active = @Active WHERE Customer_Id = @Customer_Id";

            DeclareSqlCmdParameter(sqlCmd, customer);

            int_Result = SqlConjunction.GetSQLVoid(sqlCmd);

            sqlCmd = null;

            return(int_Result);
        }
コード例 #14
0
        public int DeleteData(DECustomer customer)
        {
            int int_Result;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "DELETE FROM tbl_Customer  WHERE Customer_Id = @Customer_Id";

            DeclareSqlCmdParameter(sqlCmd, customer);

            int_Result = SqlConjunction.GetSQLVoid(sqlCmd);

            sqlCmd = null;

            return(int_Result);
        }
コード例 #15
0
        public int UpdateData(DECustomer customer)
        {
            int int_Result;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "UPDATE tbl_Customer SET Customer_Id= @Customer_Id, Customer_Description=@Customer_Description, Address = @Address, Phone = @Phone, Active = @Active ,ModifiedBy = @ModifiedBy ,ModifiedDate = @ModifiedDate, Catagory_Id = @Catagory_Id WHERE Customer_Id = @Customer_Id";

            DeclareSqlCmdParameter(sqlCmd, customer);

            int_Result = SqlConjunction.GetSQLVoid(sqlCmd);

            sqlCmd = null;

            return(int_Result);
        }
コード例 #16
0
        private void AssignData(DECustomer customer)
        {
            customer.Customer_Id          = Convert.ToInt32(txt_CustomerDescription.Tag);
            customer.Customer_Description = txt_CustomerDescription.Text.Trim();

            try
            {
                customer.Catagory_Id = Convert.ToInt32(cbx_Catagory.SelectedItem.Col3);
            }
            catch (Exception ex)
            {
                customer.Catagory_Id = 0;
            }

            customer.Address    = txt_Address.Text;
            customer.Phone      = txt_PhoneNo.Text;
            customer.ModifiedBy = DEGlobal.str_UserName;
        }
コード例 #17
0
        public int InsertData(DECustomer customer)
        {
            DALCustomer obj_DALCustomer = new DALCustomer();

            int int_Result;

            if (customer.Customer_Id == 0)
            {
                int_Result = obj_DALCustomer.InsertData(customer);
            }
            else
            {
                int_Result = obj_DALCustomer.UpdateData(customer);
            }

            obj_DALCustomer = null;

            return(int_Result);
        }
コード例 #18
0
        public Boolean LoadCustomerRow(DECustomer customer)
        {
            Boolean bool_HasRows = false;

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "SELECT Cus.Customer_Id,Cus.Customer_Description,Cus.Address,Cus.Phone, Cus.Catagory_Id,Cat.Catagory_Description, Cus.Active,Cus.ModifiedBy,Cus.ModifiedDate FROM tbl_Customer Cus LEFT JOIN tbl_CustomerCatagory Cat on Cus.Catagory_Id = Cat.Catagory_Id Where Customer_Id=@Customer_Id";

            sqlCmd = DeclareSqlCmdParameter(sqlCmd, customer);

            SqlConnection con = new SqlConnection(SqlConjunction.DataConn);

            SqlDataReader sqlDataReader = SqlConjunction.GetSQLExecuteReader(sqlCmd, con);

            while (sqlDataReader.Read())
            {
                customer.Customer_Id          = sqlDataReader.GetInt32(0);
                customer.Customer_Description = sqlDataReader.GetString(1);
                customer.Address     = sqlDataReader.GetString(2);
                customer.Phone       = sqlDataReader.GetString(3);
                customer.Catagory_Id = sqlDataReader.GetInt32(4);
                //customer.Catagory_Description = sqlDataReader.GetString(5);
                customer.Active       = sqlDataReader.GetBoolean(6);
                customer.ModifiedBy   = sqlDataReader.GetString(7);
                customer.ModifiedDate = sqlDataReader.GetDateTime(8);
            }

            if (sqlDataReader.HasRows)
            {
                bool_HasRows = true;
            }
            else
            {
                bool_HasRows = false;
            }
            con.Close();

            sqlCmd = null;

            return(bool_HasRows);
        }
コード例 #19
0
        private void dgv_Customer_DoubleClick(object sender, EventArgs e)
        {
            DECustomer customer = new DECustomer();

            customer.Customer_Id = Convert.ToInt32(dgv_Customer.CurrentRow.Cells[1].Value);

            BLLCustomer obj_BLLCustomer = new BLLCustomer();
            bool        bool_Result     = obj_BLLCustomer.LoadCustomerRow(customer);

            if (bool_Result == true)
            {
                DisplayData(customer);
            }
            else
            {
                MessageBox.Show("Record is not found.");
            }

            customer        = null;
            obj_BLLCustomer = null;
        }
コード例 #20
0
        private void search()
        {
            if (false) //(cbx_Customer.Text.Trim().Length == 0 || cbx_Customer.SelectedValue == null)
            {
                ErrorProvider.SetError(cbx_Customer, "Please Select Customer");
                string str_error = ErrorProvider.GetError(cbx_Customer);
                MessageBox.Show(str_error);

                ErrorProvider.Clear();
            }
            else
            {
                BLLInvoice obj_BLLInvoice = new BLLInvoice();

                DECustomer customer = new DECustomer();
                DEInvoice  invoice  = new DEInvoice();

                DECatagory category = new DECatagory();

                DateTime dateTime_From = Convert.ToDateTime(dtp_InvoiceDateFrom.Value);
                DateTime dateTime_To   = Convert.ToDateTime(dtp_InvoiceDateTo.Value.Date.AddHours(23.9));

                try
                {
                    customer.Catagory_Id          = Convert.ToInt32(cbx_CustomerGroup.SelectedItem.Col3);
                    customer.Catagory_Description = cbx_CustomerGroup.SelectedText;
                }
                catch (Exception ex)
                {
                    customer.Catagory_Id          = 0;
                    customer.Customer_Description = "";
                }

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

                try
                {
                    category.Catagory_Id = Convert.ToInt32(cbx_Category.SelectedItem.Col3);
                }
                catch (Exception ex)
                {
                    category.Catagory_Id = 0;
                }

                invoice.Customer_Id           = customer.Customer_Id;
                customer.Customer_Description = cbx_Customer.Text;
                customer.Address = txt_Address.Text;
                customer.Phone   = txt_PhoneNo.Text;

                DataTable dt_Sale   = new DataTable();
                DataTable dt_Return = new DataTable();

                if (rdo_Customer.Checked)
                {
                    dt_Sale   = obj_BLLInvoice.LoadInvoiceDetailTableForAllDataByInvoiceDateCustomerId(invoice.Customer_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                    dt_Return = obj_BLLInvoice.LoadProductReturnSummaryTableForAllDataByInvoiceDateCustomerId(invoice.Customer_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                }
                else
                {
                    dt_Sale   = obj_BLLInvoice.LoadInvoiceDetailTableForAllDataByInvoiceDateCustomerGroupId(customer.Catagory_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                    dt_Return = obj_BLLInvoice.LoadProductReturnSummaryTableForAllDataByInvoiceDateCustomerId(customer.Catagory_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                }

                if (rdo_Sale.Checked == true)
                {
                    bindSaleReport(customer, dt_Sale);
                }
                else
                {
                    bindReturnReport(customer, dt_Return);
                }
            }
        }