コード例 #1
0
ファイル: DeaCustDAL.cs プロジェクト: RajPujara/IMS_SOFTWARE
        public bool Delete(DeaCustBLL dc)
        {
            //SQlConnection for Database Connection
            SqlConnection conn = new SqlConnection(myconnstrng);

            //Create a Boolean Variable and set its default value to false
            bool isSuccess = false;

            try
            {
                //SQL Query to Delete Data from dAtabase
                string sql = "DELETE FROM tbl_dea_cust WHERE id=@id";

                //SQL command to pass the value
                SqlCommand cmd = new SqlCommand(sql, conn);
                //Passing the value
                cmd.Parameters.AddWithValue("@id", dc.id);

                //Open DB Connection
                conn.Open();
                //integer variable
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    //Query Executed Successfully
                    isSuccess = true;
                }
                else
                {
                    //Failed to Execute Query
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
コード例 #2
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            string keyword = txtSearch.Text;

            if (keyword == "")
            {
                txtName.Text    = "";
                txtEmail.Text   = "";
                txtContact.Text = "";
                txtAddress.Text = "";
                return;
            }
            DeaCustBLL dc = dcDAL.SearchDealerCustomerForTransation(keyword);

            txtName.Text    = dc.name;
            txtEmail.Text   = dc.email;
            txtContact.Text = dc.contact;
            txtAddress.Text = dc.address;
        }
コード例 #3
0
ファイル: DeaCustDAL.cs プロジェクト: wonghodominic/C-sharp
        public bool Update(DeaCustBLL dc)
        {
            SqlConnection conn      = new SqlConnection(myconnstrng);
            bool          isSuccess = false;

            try
            {
                string     sql = "UPDATE tbl_dea_cust SET type=@type, name=@name, email=@email, contact=@contact, address=@address, added_date=@added_date, added_by=@added_by WHERE id=@id";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@type", dc.type);
                cmd.Parameters.AddWithValue("@name", dc.name);
                cmd.Parameters.AddWithValue("@email", dc.email);
                cmd.Parameters.AddWithValue("@contact", dc.contact);
                cmd.Parameters.AddWithValue("@address", dc.address);
                cmd.Parameters.AddWithValue("@added_date", dc.added_date);
                cmd.Parameters.AddWithValue("@added_by", dc.added_by);
                cmd.Parameters.AddWithValue("@id", dc.id);


                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #4
0
        public bool Insert(DeaCustBLL d)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String     sql = "INSERT INTO tbl_dea_cust (type,name,email,contact,address,added_date,added_by) values (@type,@name,@email,@contact,@address,@added_date,@added_by) ";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@type", d.type);
                cmd.Parameters.AddWithValue("@name", d.name);
                cmd.Parameters.AddWithValue("@email", d.email);
                cmd.Parameters.AddWithValue("@contact", d.contact);
                cmd.Parameters.AddWithValue("@address", d.address);
                cmd.Parameters.AddWithValue("@added_date", d.added_date);
                cmd.Parameters.AddWithValue("@added_by", d.added_by);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //if the  query is execute Successfully then ethe value to rows will be greater than 0 else it will be less than 0
                if (rows > 0)
                {
                    //Query Successfuly
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
        public DeaCustBLL SearchDealerCustomerForTransaction(string keyword)
        {
            //create an object for DeaCustBLL class
            DeaCustBLL dc = new DeaCustBLL();
            //create a database connection
            SqlConnection conn = new SqlConnection(myconnstrng);
            //create a dtatable to hold the value temporarily
            DataTable dt = new DataTable();

            try
            {
                //write a query to search deale or customer based on keywords
                string sql = "SELECT name, email, contact, address FROM tbl_dea_cust WHERE id LIKE '%" + keyword + "%' OR name LIKE '%" + keyword + "%'";

                //create sql data adapter to execute the query
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
                //open the database connection
                conn.Open();

                //transfer the data from sqldata adapter to data table
                adapter.Fill(dt);

                //if we have values on dt we need to save it in deALERcUSTOMER bll
                if (dt.Rows.Count > 0)
                {
                    dc.name    = dt.Rows[0]["name"].ToString();
                    dc.email   = dt.Rows[0]["email"].ToString();
                    dc.contact = dt.Rows[0]["contact"].ToString();
                    dc.address = dt.Rows[0]["address"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //close database connection
                conn.Close();
            }

            return(dc);
        }
        public bool Delete(DeaCustBLL dc)
        {
            //create a boolean variable and set its value to false
            bool isSuccess = false;
            //sql connection for database connection
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //sql query to delete from database
                string sql = "DELETE FROM tbl_dea_cust WHERE id=@id";

                SqlCommand cmd = new SqlCommand(sql, conn);
                //passing the value using cmd
                cmd.Parameters.AddWithValue("@id", dc.id);

                //open sqlconnection
                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //if the query executed successfully then the vqlue of rows will be greater than 0, else less tham 0
                if (rows > 0)
                {
                    //query executed successfully
                    isSuccess = true;
                }
                else
                {
                    //failed to xecute query
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #7
0
        public DeaCustBLL GetDeaCustIDFromName(string Name)
        {
            //first create object of DeaCustBLL and return it.
            DeaCustBLL dc = new DeaCustBLL();

            //SQL connection here
            SqlConnection conn = new SqlConnection(myconnstrng);
            //create data table to hold the data temporarily
            DataTable dt = new DataTable();

            try
            {
                //Sql Quary to get customer or dealer ID based on NAme.
                string sql = "SELECT id FROM tbl_dea_cust WHERE name='" + Name + "'";

                //Create sql Adapter to Execute the Quary
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);

                //opening Database connection
                conn.Open();

                //passing value from adapter to DataTable dt
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    //passing the value from dt to DeaCust dc.
                    dc.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(dc);

            return(dc);
        }
コード例 #8
0
ファイル: DeaCustDAL.cs プロジェクト: wonghodominic/C-sharp
        public bool Insert(DeaCustBLL dc)
        {
            SqlConnection conn      = new SqlConnection(myconnstrng);
            bool          isSuccess = false;

            try
            {
                string sql = "INSERT INTO tbl_dea_cust (type, name, email, contact, address, added_date, added_by) VALUES (@type, @name, @email, @contact, @address, @added_date, @added_by)";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@type", dc.type);
                cmd.Parameters.AddWithValue("@name", dc.name);
                cmd.Parameters.AddWithValue("@email", dc.email);
                cmd.Parameters.AddWithValue("@contact", dc.contact);
                cmd.Parameters.AddWithValue("@address", dc.address);
                cmd.Parameters.AddWithValue("@added_date", dc.added_date);
                cmd.Parameters.AddWithValue("@added_by", dc.added_by);


                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #9
0
        public DeaCustBLL GetDeaCustIDFromName(string Name)
        {
            //create an object of DeaCustBLL and return it
            DeaCustBLL dc = new DeaCustBLL();

            //SQL Connection
            SqlConnection conn = new SqlConnection(myconnectstring);

            //DataTable to hold data
            DataTable dt = new DataTable();

            try
            {
                //SQL Query to get ID Based on Name
                string sql = "SELECT id FROM tbl_dea_cust WHERE name = '" + Name + "'";

                //Create SQL DataAdapter to execute the query
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);

                conn.Open();

                //Passing the value from Adapter to DataTable
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    //Pass the value from dt to DeaCustBLL dc
                    dc.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(dc);
        }
コード例 #10
0
        public DeaCustBLL GetDeaCustIDFromName(string Name)
        {
            //First Create an Object of DeaCust BLL and Return it
            DeaCustBLL dc = new DeaCustBLL();

            //Sql Connnection here
            SqlConnection conn = new SqlConnection(myconnstrng);

            //Data Table to Hold the Data temporarily
            DataTable dt = new DataTable();

            try
            {
                //SQL Query to Get id Based on Name
                string sql = "SELECT id FROM tbl_dea_cust WHERE name ='" + Name + "'";

                //Create the SQL Data Adapter to Execute the Query
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);

                conn.Open();

                //Passing the value from Adpter to DataTable
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    //Pass the value from dt to DeaCustBLL dc
                    dc.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                //Show the Error When Message
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(dc);
        }
コード例 #11
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            //get the keyword from textbox
            string keyword = txtSearch.Text;

            if (keyword == "")
            {
                txtName.Text    = "";
                txtEmail.Text   = "";
                txtContact.Text = "";
                txtAddress.Text = "";
                return;
            }
            //write the code to get the details and set the value on textboxes
            DeaCustBLL dc = dcDAL.SearchDealerCustomerForTransaction(keyword);

            //now transfer or set the value from DeaCustBLL to textboxes
            txtName.Text    = dc.name;
            txtEmail.Text   = dc.email;
            txtContact.Text = dc.contact;
            txtAddress.Text = dc.address;
        }
コード例 #12
0
        public DeaCustBLL SearchDealerCustomerForTransaction(string keyword)
        {
            // create an object for DeaCustBLL
            DeaCustBLL dc = new DeaCustBLL();
            // Create a Db Connection
            SqlConnection conn = new SqlConnection(myconnstrng);
            // create a data Table to hold the value Temporarily
            DataTable dt = new DataTable();

            try
            {
                //write a sql query to search dealer or customer based on keywords
                string sql = "select name, email, contact, address from tbl_dea_cust where id like '%" + keyword + "%' or name like '%" + keyword + "%'";

                // create sql Data Adapter to excute the query
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);

                // transfer the data to datatable
                adapter.Fill(dt);

                // if we have values in dt we need to save it in dealerCustomer BLL
                if (dt.Rows.Count > 0)
                {
                    dc.name    = dt.Rows[0]["name"].ToString();
                    dc.email   = dt.Rows[0]["email"].ToString();
                    dc.contact = dt.Rows[0]["contact"].ToString();
                    dc.address = dt.Rows[0]["address"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(dc);
        }
コード例 #13
0
        public bool Delete(DeaCustBLL dc)
        {
            //create a boolean variable and set its dafault value to false
            bool isSuccess = false;
            //connecting to database
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //sql query to delete from database
                string sql = "DELETE FROM tbl_dea_cust WHERE id=@id";
                //creating sql command to pass valuesin our query
                SqlCommand cmd = new SqlCommand(sql, conn);
                //passing values through parameters
                cmd.Parameters.AddWithValue("@id", dc.id);
                //open database connection
                conn.Open();
                //creating the int variable to execute query
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #14
0
        public DeaCustBLL GetDeaCustIDFromName(string Name)
        {
            // first create an obj of Deacust BLL and return it
            DeaCustBLL dc = new DeaCustBLL();
            // Sql Connection here
            SqlConnection conn = new SqlConnection(myconnstrng);

            // Data table to hold data temporarily
            DataTable dt = new DataTable();

            try
            {
                // sql query to get ID based oon name
                string sql = "select id from tbl_dea_cust where name='" + Name + "'";
                // sql Data Adapter to excute query
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);

                conn.Open();

                // passing the value from adapter to data table
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    //Pass the value from dt to DeaCustBLL dc
                    dc.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(dc);
        }
コード例 #15
0
        public bool Delete(DeaCustBLL dc)
        {
            // SQL connection for database connection
            SqlConnection conn = new SqlConnection(myconnstrng);
            // create a boolean variable and set its default value to false
            bool isSuccess = false;

            try
            {
                // SQl Query to delete data from database
                string sql = "delete from tbl_dea_cust where id=@id";
                // sql command to pass value
                SqlCommand cmd = new SqlCommand(sql, conn);
                // pass the value
                cmd.Parameters.AddWithValue("@id", dc.id);
                // open DB connection
                conn.Open();
                // int varable to check delete is successful
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #16
0
ファイル: DeaCustDAL.cs プロジェクト: wonghodominic/C-sharp
        public bool Delete(DeaCustBLL dc)
        {
            SqlConnection conn = new SqlConnection(myconnstrng);


            bool isSuccess = false;

            try
            {
                string     sql = "DELETE FROM tbl_dea_cust WHERE id=@id";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@id", dc.id);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #17
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            //Get the Keyword from TextBox
            string keywords = txtSearch.Text;

            if (keywords == "")
            {
                //Clear all the TextBoxs
                txtName.Text    = "";
                txtEmail.Text   = "";
                txtContact.Text = "";
                txtAddress.Text = "";
                return;
            }

            //Write the code to get the details and set the value on textboxes
            DeaCustBLL dc = dcDAL.SearchDealerCustomerForTransaction(keywords);

            //Set the value from DeaCustBLL to TextBoxs
            txtName.Text    = dc.name;
            txtEmail.Text   = dc.email;
            txtContact.Text = dc.contact;
            txtAddress.Text = dc.address;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //get the details purchase from the for textboxes
                transactionsBLL transaction = new transactionsBLL();

                transaction.type = lblTop.Text;

                //get the id of dealer or customer
                //get the name of the dealer or customer
                string deaCustName = txtName.Text;

                DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName);

                transaction.dea_cust_id      = dc.id;
                transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
                transaction.transaction_date = DateTime.Now;
                transaction.tax      = decimal.Parse(txtVat.Text);
                transaction.discount = decimal.Parse(txtDiscount.Text);

                //get the username of logged in user
                string username = frmLogin.loggedIn;

                userBLL u = uDAL.GetIDFromUsername(username);

                transaction.added_by           = u.id;
                transaction.transactionDetails = transactionDT;

                //create a boolean variable and set its value to false
                bool success = false;

                //code to INSert TRansaction and Transaction details
                using (TransactionScope scope = new TransactionScope())
                {
                    int transactionID = -1;
                    //create a boolean value and insert transaction
                    bool w = tDAL.Insert_Transaction(transaction, out transactionID);

                    //use for loop to inser transaction details
                    for (int i = 0; i < transactionDT.Rows.Count; i++)
                    {
                        //get all the details of the roduct
                        transactionDetailBLL transactionDetail = new transactionDetailBLL();
                        //get the product name and convert it to ID
                        string      productName = transactionDT.Rows[i][0].ToString();
                        productsBLL p           = pDAL.GetProductIDFromName(productName);

                        transactionDetail.product_id  = p.id;
                        transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                        transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                        transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                        transactionDetail.dea_cust_id = dc.id;
                        transactionDetail.added_date  = DateTime.Now;
                        transactionDetail.added_by    = u.id;

                        //Increase or Decrease Product Qty based on purchase or sales
                        string transactionType = lblTop.Text;

                        //check whether its on purchase or sale
                        bool x = false;
                        if (transactionType == "Purchase")
                        {
                            //increse the product qty
                            x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }
                        else if (transactionType == "Sales")
                        {
                            //decrease the product qty
                            x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }

                        //Insert Transaction details inside the database
                        bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                        success = w && x && y;
                    }

                    if (success == true)
                    {
                        //Transaction comlete
                        scope.Complete();
                        MessageBox.Show("Transaction Completed Successfully!");
                        //clear the data grid view and clear all he textboxes
                        dgvAddedProducts.DataSource = null;
                        dgvAddedProducts.Rows.Clear();

                        txtSearch.Text        = "";
                        txtName.Text          = "";
                        txtEmail.Text         = "";
                        txtAddress.Text       = "";
                        txtContact.Text       = "";
                        txtSearchProduct.Text = "";
                        txtProductName.Text   = "";
                        txtInventory.Text     = "0";
                        txtRate.Text          = "0";
                        txtQty.Text           = "0";
                        txtSubTotal.Text      = "0";
                        txtDiscount.Text      = "0"; //////////0
                        txtGrandTotal.Text    = "0";
                        txtVat.Text           = "0"; /////////0
                        txtPaidAmount.Text    = "0";
                        txtReturnAmount.Text  = "0";
                    }
                    else
                    {
                        //Transaction failed
                        MessageBox.Show("Transaction Failed!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #19
0
        public bool Insert(DeaCustBLL dc)
        {
            // creating a boolean variable and setting its default value to false

            bool isSuccess = false;

            // creating sql connection to database. This will be in between bool variable isSuccess and we have returned it as well.

            SqlConnection conn = new SqlConnection(myconnstring);

            // start block

            try
            {
                // writing SQL Query to get all data from database

                string sql = "INSERT INTO tbl_dea_cust (type,name,email,contact,address,added_date,added_by) VALUES (@type,@name,@email,@contact,@address,@added_date,@added_by)";

                // create sql command to pass values
                SqlCommand cmd = new SqlCommand(sql, conn);

                //passing values through parameters

                cmd.Parameters.AddWithValue("@type", dc.type);
                cmd.Parameters.AddWithValue("@name", dc.name);
                cmd.Parameters.AddWithValue("@email", dc.email);
                cmd.Parameters.AddWithValue("@contact", dc.contact);
                cmd.Parameters.AddWithValue("@address", dc.address);
                cmd.Parameters.AddWithValue("@added_date", dc.added_date);
                cmd.Parameters.AddWithValue("@added_by", dc.added_by);

                // Open connection
                conn.Open();

                //creating int variable to execute query
                int rows = cmd.ExecuteNonQuery();

                //if the query is executed successfully then its value will be greater than zero else less than zero

                if (rows > 0)
                {
                    // Query executed Successfully
                    isSuccess = true;
                }
                else
                {
                    // Query Not Done successfully
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }


            return(isSuccess);
        }
コード例 #20
0
        public bool Update(DeaCustBLL dc)
        {
            // creating boolean variable and set its value to false

            bool isSuccess = false;

            // write query to update. Write SQL Connection

            SqlConnection conn = new SqlConnection(myconnstring);


            try
            {
                // writing SQL Query to get all data from database. We wil lalways add id into Update

                string sql = "UPDATE tbl_dea_cust SET type=@type,name=@name,email=@email,contact=@contact,address=@address,added_date=@added_date,added_by=@added_by WHERE id=@id";

                // create sql command to pass values to query

                SqlCommand cmd = new SqlCommand(sql, conn);

                //passing values through parameters

                cmd.Parameters.AddWithValue("@type", dc.type);
                cmd.Parameters.AddWithValue("@name", dc.name);
                cmd.Parameters.AddWithValue("@email", dc.email);
                cmd.Parameters.AddWithValue("@contact", dc.contact);
                cmd.Parameters.AddWithValue("@address", dc.address);
                cmd.Parameters.AddWithValue("@added_date", dc.added_date);
                cmd.Parameters.AddWithValue("@added_by", dc.added_by);
                cmd.Parameters.AddWithValue("@id", dc.id);

                // Open connection
                conn.Open();

                //creating int variable to execute query
                int rows = cmd.ExecuteNonQuery();

                //if the query is executed successfully then its value will be greater than zero else less than zero

                if (rows > 0)
                {
                    // Query executed Successfully
                    isSuccess = true;
                }
                else
                {
                    // Query Not Done successfully
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
コード例 #21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                transactionsBLL transaction = new transactionsBLL();
                transaction.type = lblTop.Text;
                string deaCustName = txtName.Text;

                DeaCustBLL dc = dcDAL.GetDeaCustIdFromName(deaCustName);
                transaction.dea_cust_id      = dc.Id;
                transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
                transaction.transaction_date = DateTime.Now;
                transaction.tax      = decimal.Parse(txtVat.Text);
                transaction.discount = decimal.Parse(txtDiscount.Text);

                string  username = frmLogin.loggedIn;
                userBLL u        = uDAL.GetIdFromUsername(username);

                transaction.added_by           = u.Id;
                transaction.transactionDetails = transactionDT;

                bool success = false;
                using (TransactionScope scope = new TransactionScope())
                {
                    int  transactionId = -1;
                    bool w             = tDAL.Insert_Transaction(transaction, out transactionId);

                    for (int i = 0; i < transactionDT.Rows.Count; i++)
                    {
                        transactionDetailBLL transactionDetail = new transactionDetailBLL();
                        string      productName = transactionDT.Rows[i][0].ToString();
                        productsBLL p           = pdal.GetProductIdFromName(productName);
                        transactionDetail.product_id  = p.Id;
                        transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                        transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                        transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                        transactionDetail.dea_cust_id = dc.Id;
                        transactionDetail.added_date  = DateTime.Now;
                        transactionDetail.added_by    = u.Id;


                        string transactionType = lblTop.Text;
                        bool   x = false;
                        if (transactionType == "PURCHASE")
                        {
                            x = pdal.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }
                        else if (transactionType == "SALES")
                        {
                            x = pdal.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }

                        bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                        success = w && x && y;
                    }

                    if (success == true)
                    {
                        scope.Complete();
                        MassageBox mb = new MassageBox("Transaction Success", MsgType.success);
                        mb.Show();
                        //MessageBox.Show("Transaction Completed Successfully...");
                        dgvAddedProducts.DataSource = null;
                        dgvAddedProducts.Rows.Clear();

                        txtSearch.Text        = "";
                        txtName.Text          = "";
                        txtEmail.Text         = "";
                        txtContact.Text       = "";
                        txtAddress.Text       = "";
                        txtSearchProduct.Text = "";
                        txtNamePro.Text       = "";
                        txtInventory.Text     = "0";
                        txtRate.Text          = "0";
                        txtQty.Text           = "0";
                        txtSubTotal.Text      = "0";
                        txtDiscount.Text      = "0";
                        txtVat.Text           = "0";
                        txtGrandTotal.Text    = "0";
                        txtPaidAmount.Text    = "0";
                        txtReturnAmount.Text  = "0";
                    }
                    else
                    {
                        MassageBox mb = new MassageBox("Transaction Failed", MsgType.retry);
                        mb.Show();
                        //MessageBox.Show("Transaction Failed...!!! Try again");
                    }
                }
            }catch (Exception)
            {
                MassageBox mb = new MassageBox("ERROR", MsgType.clear);
                mb.BackColor = Color.Crimson;
                mb.Show();
            }
        }
コード例 #22
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //get the values from purchaseSales form first
            transactionsBLL transaction = new transactionsBLL();

            transaction.type = lblTop.Text;
            //get the id of dealer and customer here
            //lets get name of dealer or customer first
            string     deaCustName = txtName.Text;
            DeaCustBLL dc          = dcDAL.GetDeaCustIdFromName(deaCustName);

            transaction.dea_cust_id      = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtVat.Text);
            transaction.discount = decimal.Parse(txtDiscount.Text);
            //get the username of looged in user
            string  username = frmLogin.loggedIn;
            userBLL u        = uDAL.GetIDFromUsername(username);

            transaction.added_by           = u.id;
            transaction.transactionDetails = transactionDT;

            bool success = false;

            //actual code to insert transaction and transaction detail
            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;
                //create boolean value and insert transaction
                bool w = tDAL.Insert_Transaction(transaction, out transactionID);

                //use for loop to insert transaction details
                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    // get all the details of the product
                    transactionDetailBLL transactionDetail = new transactionDetailBLL();
                    //get the product name and convert it to id
                    string      ProductName = transactionDT.Rows[i][1].ToString();
                    productsBLL p           = pDAL.GetProductIDFromName(ProductName);
                    transactionDetail.product_id  = p.id;
                    transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][3].ToString());
                    transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][4].ToString()), 2);
                    transactionDetail.dea_cust_id = dc.id;
                    transactionDetail.added_date  = DateTime.Now;
                    transactionDetail.added_by    = u.id;

                    //here increse or decrease product qty based on purchase or sale
                    string transactionType = lblTop.Text;

                    //lets check whether we are on purchase or sale form
                    bool x = false;
                    if (transactionType == "Purchase")
                    {
                        //Increase the product
                        x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }
                    else if (transactionType == "Sales")
                    {
                        //Decrease the product qty
                        x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }


                    //insert transactiondetail inside the database
                    bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                    success = w && x && y;
                }

                if (success == true)
                {
                    //Transaction complete
                    scope.Complete();

                    //code to print bill
                    DGVPrinter printer = new DGVPrinter();
                    printer.Title               = "\r\n\r\n\r\n GKN INVENTORY PVT.LTD.\r\n\r\n";
                    printer.SubTitle            = "Kolkata, WestBengal \r\n Phone:+91-9765XXXXXX\r\n\r\n";
                    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    printer.PageNumbers         = true;
                    printer.PageNumberInHeader  = false;
                    printer.PorportionalColumns = true;
                    printer.HeaderCellAlignment = StringAlignment.Near;
                    printer.Footer              = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: Rs. " + txtGrandTotal.Text + "\r\n\r\n" + "Thank you For doing business with us.";
                    printer.FooterSpacing       = 15;
                    printer.PrintDataGridView(dgvAddedProducts);

                    MessageBox.Show("Transaction Completed Successfully.");
                    //clear the data grid view and clear all the textboxes
                    dgvAddedProducts.DataSource = null;
                    dgvAddedProducts.Rows.Clear();

                    txtSearch.Text        = "";
                    txtName.Text          = "";
                    txtEmail.Text         = "";
                    txtContact.Text       = "";
                    txtAddress.Text       = "";
                    txtSearchProduct.Text = "";
                    txtproductid.Text     = "";
                    txtProductName.Text   = "";
                    txtInventory.Text     = "0";
                    txtRate.Text          = "0";
                    txtQty.Text           = "0";
                    txtSubTotal.Text      = "0";
                    txtDiscount.Text      = "0";
                    txtVat.Text           = "0";
                    txtGrandTotal.Text    = "0";
                    txtPaidAmount.Text    = "0";
                    txtReturnAmount.Text  = "0";
                }
                else
                {
                    //Transaction failed
                    MessageBox.Show("Transaction Failed.");
                }
            }
        }
コード例 #23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Get the values from purchase sales from first
            transactionsBLL transaction = new transactionsBLL();

            transaction.type = lblTop.Text;

            //Get the id of Dealer and Customer
            //Lets get the name of the dealer and customer first
            string     deaCustName = txtName.Text;
            DeaCustBLL dc          = dcDAL.GetDeaCustIDFromName(deaCustName);

            transaction.dea_cust_id      = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.ig             = decimal.Parse(txtig.Text);
            transaction.cg             = decimal.Parse(txtcg.Text);
            transaction.sg             = decimal.Parse(txtsg.Text);
            transaction.igamount       = decimal.Parse(textigstamount.Text);
            transaction.cgamount       = decimal.Parse(textcgstamount.Text);
            transaction.sgamount       = decimal.Parse(textsgstamount.Text);
            transaction.discount       = decimal.Parse(txtDiscount.Text);
            transaction.discountamount = decimal.Parse(textdiscoutamount.Text);

            //Get the username of logged in user
            string  username = frmLogin.loggedIn;
            userBLL u        = uDAL.GetIDFromUsername(username);

            transaction.added_by           = u.id;
            transaction.transactionDetails = transactionDT;

            //Create a Boolean Variable and set its value to false
            bool success = false;

            //Actual code to Insert Transaction and transactionDetails
            using (TransactionScope scope = new TransactionScope())
            {
                int tranactionID = -1;

                //Create a Boolean Value and Insert Transaction
                bool w = tDAL.Insert_Transaction(transaction, out tranactionID);

                //Use for loop to insert transaction details
                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    //Get all the details of the product
                    transactionDetailBLL transactionDetail = new transactionDetailBLL();

                    //Get the product name and convert it to ID
                    string      ProductName = transactionDT.Rows[i][0].ToString();
                    productsBLL p           = pDAL.GetProductIDFromName(ProductName);

                    transactionDetail.product_id  = p.id;
                    transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                    transactionDetail.dea_cust_id = dc.id;
                    transactionDetail.added_date  = DateTime.Now;
                    transactionDetail.added_by    = u.id;

                    //Increase or Decrease Product Quantity Based on Purchase or Sales
                    string transactionType = lblTop.Text;

                    //Check Whetehr we are on purchase or sales
                    bool x = false;
                    if (transactionType == "Purchase")
                    {
                        //Increase the Product
                        x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }
                    else if (transactionType == "Sales")
                    {
                        //Decrease Product Quantity
                        x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }

                    //Insert TransactionDetails inside our database
                    bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                    success = w && x && y;
                }

                if (success == true)
                {
                    //Transaction Complete
                    scope.Complete();

                    label6.Text  = txtSubTotal.Text;
                    label7.Text  = txtDiscount.Text;
                    label8.Text  = txtcg.Text;
                    label9.Text  = txtig.Text;
                    label10.Text = txtsg.Text;
                    label11.Text = textcgstamount.Text;
                    label12.Text = textigstamount.Text;
                    label13.Text = textsgstamount.Text;
                    label14.Text = txtGrandTotal.Text;
                    label15.Text = textdiscoutamount.Text;

                    MessageBox.Show("Transaction Completed Successfully.");
                    comboBox1.Visible = true;


                    //Clear the data Grid View and all the TextBxs
                    dgvAddedProducts.DataSource = null;
                    dgvAddedProducts.Rows.Clear();

                    txtSearch.Text         = "";
                    txtName.Text           = "";
                    txtEmail.Text          = "";
                    txtAddress.Text        = "";
                    txtSearchProduct.Text  = "";
                    txtProductName.Text    = "";
                    txtInventory.Text      = "";
                    txtRate.Text           = "";
                    txtQty.Text            = "";
                    txtSubTotal.Text       = "0";
                    txtDiscount.Text       = "0";
                    txtig.Text             = "0";
                    txtcg.Text             = "0";
                    txtsg.Text             = "0";
                    textigstamount.Text    = "0";
                    textsgstamount.Text    = "0";
                    textcgstamount.Text    = "0";
                    textdiscoutamount.Text = "0";
                    txtGrandTotal.Text     = "0";
                    txtPaidAmount.Text     = "";
                }
                else
                {
                    MessageBox.Show("Transaction Failed.");
                }
            }
        }
コード例 #24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Get the Values from PurchaseSales Form First
            transactionsBLL transaction = new transactionsBLL();

            transaction.type = lblTop.Text;

            //Get the ID of Dealer or Customer Here
            //Lets get name of the dealer or customer first
            string     deaCustName = txtName.Text;
            DeaCustBLL dc          = dcDAL.GetDeaCustIDFromName(deaCustName);

            transaction.dea_cust_id      = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtVat.Text);
            transaction.discount = decimal.Parse(txtDiscount.Text);

            //Get the Username of Logged in user
            string  username = frmLogin.loggedIn;
            userBLL u        = uDAL.GetIDFromUsername(username);

            transaction.added_by           = u.id;
            transaction.transactionDetails = transactionDT;

            //Lets Create a Boolean Variable and set its value to false
            bool success = false;

            //Actual Code to Insert Transaction And Transaction Details
            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;
                //Create aboolean value and insert transaction
                bool w = tDAL.Insert_Transaction(transaction, out transactionID);

                //Use for loop to insert Transaction Details
                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    //Get all the details of the product
                    transactionDetailBLL transactionDetail = new transactionDetailBLL();
                    //Get the Product name and convert it to id
                    string      ProductName = transactionDT.Rows[i][0].ToString();
                    productsBLL p           = pDAL.GetProductIDFromName(ProductName);

                    transactionDetail.product_id  = p.id;
                    transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                    transactionDetail.dea_cust_id = dc.id;
                    transactionDetail.added_date  = DateTime.Now;
                    transactionDetail.added_by    = u.id;

                    //Here Increase or Decrease Product Quantity based on Purchase or sales
                    string transactionType = lblTop.Text;

                    //Lets check whether we are on Purchase or Sales
                    bool x = false;
                    if (transactionType == "Purchase")
                    {
                        //Increase the Product
                        x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }
                    else if (transactionType == "Sales")
                    {
                        //Decrease the Product Quntiyt
                        x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }

                    //Insert Transaction Details inside the database
                    bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                    success = w && x && y;
                }

                if (success == true)
                {
                    //Transaction Complete
                    scope.Complete();

                    //Code to Print Bill
                    DGVPrinter printer = new DGVPrinter();

                    printer.Title               = "\r\n\r\n\r\n iResell\r\n\r\n";
                    printer.SubTitle            = "Dorart \r\n [email protected] \r\n\r\n";
                    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    printer.PageNumbers         = true;
                    printer.PageNumberInHeader  = false;
                    printer.PorportionalColumns = true;
                    printer.HeaderCellAlignment = StringAlignment.Near;
                    printer.Footer              = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: " + txtGrandTotal.Text + "\r\n\r\n" + "Thank you for doing business with us.";
                    printer.FooterSpacing       = 15;
                    printer.PrintDataGridView(dgvAddedProducts);

                    MessageBox.Show("Transaction Completed Sucessfully");
                    //Celar the Data Grid View and Clear all the TExtboxes
                    dgvAddedProducts.DataSource = null;
                    dgvAddedProducts.Rows.Clear();

                    txtSearch.Text        = "";
                    txtName.Text          = "";
                    txtEmail.Text         = "";
                    txtContact.Text       = "";
                    txtAddress.Text       = "";
                    txtSearchProduct.Text = "";
                    txtProductName.Text   = "";
                    txtInventory.Text     = "0";
                    txtRate.Text          = "0";
                    TxtQty.Text           = "0";
                    txtSubTotal.Text      = "0";
                    txtDiscount.Text      = "0";
                    txtVat.Text           = "0";
                    txtGrandTotal.Text    = "0";
                    txtPaidAmount.Text    = "0";
                    txtReturnAmount.Text  = "0";
                }
                else
                {
                    //Transaction Failed
                    MessageBox.Show("Transaction Failed");
                }
            }
        }
コード例 #25
0
        private void btnSaveCal_Click(object sender, EventArgs e)
        {
            //Get the Values from PurchaseSales Form First
            TransactionsBLL transaction = new TransactionsBLL();

            transaction.type = UserDashboard.TransactionType;

            //Get the ID of Dealer or Customer Here
            //Lets get name of the dealer or customer first
            string     deaCustName = txtName.Text;
            DeaCustBLL dc          = dcdal.GetDeaCustIDFromName(deaCustName);

            transaction.dea_cust_id      = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtVAT.Text);
            transaction.discount = decimal.Parse(txtDiscount.Text);

            //Get the Username of Logged in user
            string  username = Login.loggedInUser;
            UserBLL u        = udal.getIdFromUserName(username);

            transaction.added_by           = u.id;
            transaction.transactionDetails = transactionDT;

            //Lets Create a Boolean Variable and set its value to false
            bool success = false;

            //Actual Code to Insert Transaction And Transaction Details
            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;
                //Create aboolean value and insert transaction
                bool w = Tdal.Insert_Transaction(transaction, out transactionID);

                //Use for loop to insert Transaction Details
                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    //Get all the details of the product
                    transactionDetailBLL transactionDetail = new transactionDetailBLL();
                    //Get the Product name and convert it to id
                    string      ProductName = transactionDT.Rows[i][0].ToString();
                    ProductsBLL p           = pdal.GetProductIDFromName(ProductName);

                    transactionDetail.product_id  = p.id;
                    transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                    transactionDetail.dea_cust_id = dc.id;
                    transactionDetail.added_date  = DateTime.Now;
                    transactionDetail.added_by    = u.id;

                    //Here Increase or Decrease Product Quantity based on Purchase or sales
                    string transactionType = UserDashboard.TransactionType;

                    //Lets check whether we are on Purchase or Sales
                    bool x = false;
                    if (transactionType == "Purchase")
                    {
                        //Increase the Product
                        x = pdal.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }
                    else if (transactionType == "Sales")
                    {
                        //Decrease the Product Quntiyt
                        x = pdal.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }

                    //Insert Transaction Details inside the database
                    bool y = TDdal.InsertTransactionDetail(transactionDetail);
                    success = w && x && y;
                }

                if (success == true)
                {
                    //Transaction Complete
                    scope.Complete();
                    Mymessage mymessage = new Mymessage("Transaction Completed Sucessfully");
                    mymessage.Show();
                    //Celar the Data Grid View and Clear all the TExtboxes
                    GDVCustomer.DataSource = null;
                    GDVCustomer.Rows.Clear();

                    txtDeaCustSearch.Text        = "";
                    txtName.Text                 = "";
                    txtEMail.Text                = "";
                    txtContact.Text              = "";
                    txtAddress.Text              = "";
                    txtPrdctSearch.Text          = "";
                    txtPrdctName.Text            = "";
                    txtPrdctInventory.Text       = "0";
                    txtProductRate.Text          = "0";
                    txtPrdctQty.Text             = "0";
                    txtSubTotal.Text             = "0";
                    txtDiscount.Text             = "0";
                    txtVAT.Text                  = "0";
                    txtGrandTotal.Text           = "0";
                    txtPaidAmt.Text              = "0";
                    txtReturnAmount.Text         = "0";
                    printPreviewDialog1.Document = printDocument1;
                    printPreviewDialog1.ShowDialog();
                }
                else
                {
                    //Transaction Failed
                    MessageBox.Show("Transaction Failed");
                }
            }
        }