private void dgvUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int selectedRowIndex    = this.dgvUsers.SelectedCells[0].RowIndex;
            int selectedColumnIndex = this.dgvUsers.SelectedCells[0].ColumnIndex;

            if (selectedColumnIndex == 0)//update
            {
                //MessageBox.Show("update click  "+this.dgvUsers.Rows[selectedRowIndex].Cells[4].Value);access row value
                cCustomer c1 = new cCustomer();
                c1.cId       = Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[2].Value);
                c1.cFullName = this.dgvUsers.Rows[selectedRowIndex].Cells[3].Value.ToString();
                c1.cCNIC     = this.dgvUsers.Rows[selectedRowIndex].Cells[4].Value.ToString();
                c1.cAddress  = this.dgvUsers.Rows[selectedRowIndex].Cells[5].Value.ToString();
                c1.cMobileNo = this.dgvUsers.Rows[selectedRowIndex].Cells[6].Value.ToString();
                c1.cRemarks  = this.dgvUsers.Rows[selectedRowIndex].Cells[7].Value.ToString();

                new cCustomerBLL().UpdateCustomer(c1);

                dgvUsers.DataSource = "";
                dgvUsers.DataSource = new cCustomerBLL().getCustomers();
                this.dgvUsers.Columns[2].ReadOnly = true;

                MessageBox.Show("Data Updated...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (selectedColumnIndex == 1)//delete
            {
                new cCustomerBLL().RemoveCustomer(Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[2].Value));

                dgvUsers.DataSource = "";
                dgvUsers.DataSource = new cCustomerBLL().getCustomers();
                this.dgvUsers.Columns[2].ReadOnly = true;

                MessageBox.Show("Data Deleted...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        public List <cCustomer> getCustomers(string customername)
        {
            List <cCustomer> customers = new List <cCustomer>();
            SqlConnection    con       = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();

            string        query  = "select * from Customers where cFullName LIKE '%" + customername + "%'";
            SqlCommand    cmd    = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cCustomer u1 = new cCustomer();
                u1.cId       = Convert.ToInt32(reader["cId"]);
                u1.cFullName = reader["cFullName"].ToString();
                u1.cCNIC     = reader["cCNIC"].ToString();
                u1.cAddress  = reader["cAddress"].ToString();
                u1.cMobileNo = reader["cMobileNo"].ToString();
                u1.cRemarks  = reader["cRemarks"].ToString();
                customers.Add(u1);
            }
            reader.Close();
            con.Close();
            con.Dispose();
            cmd.Dispose();
            return(customers);
        }
예제 #3
0
        static void Main(string[] args)
        {
            cCustomer c1 = new cCustomer();

            cCustomer._name = "sdf";
            cCustomer._id   =
        }
예제 #4
0
        public int InsertCustomer(cCustomer customer)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State.ToString() == "open")
            {
                con.Close();
            }

            con.Open();

            string query = "INSERT into Customers (cFullname,cCNIC,cAddress,cMobileNo,cRemarks)" +
                           "values('" + customer.cFullName + "','" + customer.cCNIC + "','" + customer.cAddress + "','" + customer.cMobileNo + "','" + customer.cRemarks + "')";

            SqlCommand cmd = new SqlCommand(query, con);


            var result = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();
            con.Dispose();

            return(result);
        }
예제 #5
0
        private void GetClientgarments()
        {
            dgvColors.DataSource  = null;
            dgvDeisgns.DataSource = null;
            dgvSizes.DataSource   = null;
            dgvStyles.DataSource  = null;

            if (int.TryParse(txtClientID.Text, out _clientID))
            {
                frmLoading loading = new Forms.frmLoading();
                loading.Show();
                Application.DoEvents();
                _designStyles = DesignServices.GetDesignStylesByClientID(_clientID);
                _customer     = AccessServices.GetCustomerByClientID(_clientID);
                loading.Close();
            }
            else if (Directory.Exists(txtClientID.Text))
            {
                _designStyles = DesignServices.GetDesignStylesFromSpreadsheets(txtClientID.Text);
            }
            else
            {
                var allActiveClients = AccessServices.GetAllActiveCustomersByClientID();
                foreach (var customer in allActiveClients)
                {
                    lblCost.Text = string.Format("Creating JSON For {0}", customer.Company_Name);
                    Application.DoEvents();
                    var    cstyles      = AccessServices.GetStylesByClientID(customer.Company_ID);
                    var    cdesigns     = AccessServices.GetDesignsByClientID(customer.Company_ID);
                    var    jsonDesigns  = JsonConvert.SerializeObject(JSONGenerator.JSONGeneratorHelpers.CreateDesigns(cdesigns));
                    var    jsonStyles   = JsonConvert.SerializeObject(JSONGenerator.JSONGeneratorHelpers.CreateStyles(cstyles));
                    string jsonCustomer = JsonConvert.SerializeObject(JSONGenerator.JSONGeneratorHelpers.CreateCustomer(customer));


                    using (StreamWriter sw = new StreamWriter(@"OuputPath\JSON\" + customer.Company_ID.ToString() + "_styledesigns.js"))
                    {
                        string json = string.Format("var styles = {0} \n\r  var designs = {1} \n\r var user = {2}", jsonStyles, jsonDesigns, jsonCustomer);

                        sw.Write(json);
                    }
                }
                lblCost.Text = string.Format("Done");
                return;
            }

            var designs = _designStyles.Select(x => x.Design).Distinct().ToList();
            var styles  = _designStyles.Select(x => x.Style).Distinct().ToList();

            dgvDeisgns.DataSource = designs;
            dgvStyles.DataSource  = styles.OrderBy(x => x.Gender).Select(x => new { Number = x.Style_Number, Description = x.Gender + " " + x.Website_Description, MaxHue = x.MaxHue, MinOverride = x.MinOverride }).ToList();
            if (_customer != null)
            {
                lblCost.Text = _customer.Company_Name;
            }
        }
예제 #6
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            cCustomer  iCustomer  = new cCustomer();
            RentClass  iRent      = new RentClass();
            cUtilities iUtilities = new cUtilities();

            ExpensesClass expenses = new ExpensesClass();

            //Linking methods created in expenses class with textboxes
            expenses.theClothing      = Double.Parse(txtClothing.Text);
            expenses.theElectricity   = Double.Parse(txtElectricity.Text);
            expenses.theEntertainment = Double.Parse(txtEntertainment.Text);
            expenses.theGroceries     = Double.Parse(txtGroceries.Text);
            expenses.theInvestment    = Double.Parse(txtInvestments.Text);
            expenses.thePhone         = Double.Parse(txtPhone.Text);
            expenses.theTransport     = Double.Parse(txtTTransport.Text);
            expenses.theWater         = Double.Parse(txtWater.Text);
            expenses.theTax           = Double.Parse(txtTax.Text);
            expenses.theGrossIncome   = Double.Parse(txtGross.Text);



            //Calculations
            String t = String.Format("{0:C}", expenses.theClothing + expenses.theElectricity +
                                     expenses.theEntertainment + expenses.theGroceries + expenses.theInvestment + expenses.thePhone +
                                     expenses.theTax + expenses.theTransport + expenses.theWater);

            txtTotal.Text = t;



            //the software will printout this as a reciept
            rptExpenses.AppendText("\t\tMY EXPENSES" + "\n" + "---------------------------------------------" + "\n");
            rptExpenses.AppendText("Clothing" + "\t\t\t" + txtClothing.Text + "\n");
            rptExpenses.AppendText("Electricity" + "\t\t\t" + txtElectricity.Text + "\n");
            rptExpenses.AppendText("Entertainement" + "\t\t" + txtEntertainment.Text + "\n");
            rptExpenses.AppendText("Groceries" + "\t\t\t" + txtGroceries.Text + "\n");
            rptExpenses.AppendText("Transport " + "\t\t" + txtTTransport.Text + "\n");
            rptExpenses.AppendText("Investments" + "\t\t" + txtInvestments.Text + "\n");
            rptExpenses.AppendText("Phone" + "\t\t\t" + txtPhone.Text + "\n");
            rptExpenses.AppendText("Water" + "\t\t\t" + txtWater.Text + "\n");
            rptExpenses.AppendText("Tax" + "\t\t\t" + txtTax.Text + "\n");
            rptExpenses.AppendText("-------------------------------------------------------------------\n");
            rptExpenses.AppendText("Total" + "\t\t\t" + txtTotal.Text + "\n");
            rptExpenses.AppendText("------------------------------------------------------------------\n");
        }
예제 #7
0
        public int UpdateCustomer(cCustomer customer)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            string query = "UPDATE Customers " +
                           "SET cFullName = '" + customer.cFullName + "' , cCNIC = '" + customer.cCNIC + "' , cAddress = '" + customer.cAddress + "' , cMobileNo = '" + customer.cMobileNo + "' , cRemarks = '" + customer.cRemarks + "' " +
                           " WHERE cId ='" + customer.cId + "'";
            SqlCommand cmd    = new SqlCommand(query, con);
            var        result = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();
            con.Dispose();
            return(result);
        }
예제 #8
0
        /// <summary>
        /// Updates the cCustomer object
        /// </summary>
        /// <param name="customer">the ccustomer object</param>
        /// <returns>bool</returns>
        public static bool Update(cCustomer customer)
        {
            if (customer.Valid)
            {
                int response = cCustomerSQL.updateData(customer);

                if (response == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new Exception("One or more fields contain invalid data");
            }
        }
예제 #9
0
        private void btnRental_Click(object sender, EventArgs e)
        { //creating new classes
            cCustomer  iCustomer  = new cCustomer();
            RentClass  iRent      = new RentClass();
            cUtilities iUtilities = new cUtilities();

            // linking methods created in rent class
            iCustomer.theDeposit      = Double.Parse(txtDeposit.Text);
            iRent.theCost             = Double.Parse(txtCost.Text);
            iRent.theNumberofroom     = Double.Parse(nudRoom.Text);
            iUtilities.theElectricity = Double.Parse(txtEletricity.Text);
            iUtilities.theLocalTax    = Double.Parse(txtWaterBill.Text);
            iUtilities.theWaterBill   = Double.Parse(txtWaterBill.Text);

            //Calculations
            String q = String.Format("{0:C}", iCustomer.theDeposit + (iRent.theCost * iRent.theNumberofroom)
                                     + iUtilities.theElectricity + iUtilities.theLocalTax + iUtilities.theWaterBill);

            txtTotalPayment.Text = q;



            // Creating  printout for the recipts
            rptRent.AppendText("\t\tRENT" + "\n" + "-------------------------------------------------------------------------------" + "\n");
            rptRent.AppendText("Customer ID" + "\t\t" + txtCustomerID.Text + "\n");
            rptRent.AppendText("Firstname" + "\t\t\t" + txtFirstname.Text + "\n");
            rptRent.AppendText("Surname" + "\t\t\t" + txtSurname.Text + "\n");
            rptRent.AppendText("Address" + "\t\t\t" + txtAddress.Text + "\n");
            rptRent.AppendText("Postal Code" + "\t\t" + txtPostalCode.Text + "\n");
            rptRent.AppendText("Proof of ID" + "\t\t" + cmbMonth.Text + "\n");
            rptRent.AppendText("Town" + "\t\t\t" + txtTown.Text + "\n");
            rptRent.AppendText("--------------------------------------------------------------------------\n");

            rptRent.AppendText("Electricity" + "\t\t\t" + txtElectricity.Text + "\n");
            rptRent.AppendText("Local Tax" + "\t\t\t" + txtlocaltax.Text + "\n");
            rptRent.AppendText("Water Bill" + "\t\t\t" + txtWaterBill.Text + "\n");
            rptRent.AppendText("-------------------------------------------------------------------------\n");
            rptRent.AppendText("Total Payment" + "\t\t" + txtTotalPayment.Text + "\n");
            rptRent.AppendText("--------------------------------------------------------------------------");
        }
예제 #10
0
        public int getId(cCustomer c)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            string query = "select cId from Customers where cFullName = '" + c.cFullName + "' and cCNIC= '" + c.cCNIC + "' and cAddress ='" + c.cAddress + "' and cMobileNo = '" + c.cMobileNo + "' and cRemarks = '" + c.cRemarks + "'";

            SqlCommand cmd   = new SqlCommand(query, con);
            Int32      count = (Int32)cmd.ExecuteScalar();

            /*
             * SqlCommand cmd = new SqlCommand(query, con);
             * var result = cmd.ExecuteNonQuery();*/
            con.Close();
            cmd.Dispose();
            con.Dispose();
            return(count);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            cCustomer customer = new cCustomer();

            customer.cFullName = txtFullname.Text.Trim();
            customer.cCNIC     = txtCNIC.Text.Trim();
            customer.cAddress  = txtAddress.Text.Trim();
            customer.cMobileNo = txtMobile.Text.Trim();
            customer.cRemarks  = txtRemarks.Text.Trim();

            if (customer.cFullName != "")
            {
                if (customer.cCNIC != "")
                {
                    if (customer.cAddress != "")
                    {
                        if (customer.cMobileNo != "")
                        {
                            if (customer.cRemarks != "")
                            {
                                if (new cCustomerBLL().InsertCustomer(customer) > 0)
                                {
                                    //valid record or user
                                    /**/

                                    var          cid = new cCustomerBLL().getId(customer);//recently added customer
                                    cMeaurements m   = new cMeaurements();
                                    cDetails     d   = new cDetails();
                                    foreach (var mes in mList)
                                    {
                                        m.cId   = cid;
                                        m.mType = mes[0].tempType;
                                        new cMeaurementsBLL().InsertMeaurements(m);
                                        var mid = new cMeaurementsBLL().getId(m);
                                        foreach (var details in mes)
                                        {
                                            d.mId         = mid;
                                            d.field_name  = details.field_name;
                                            d.field_value = details.field_value;
                                            new cMeaurementsBLL().InsertDetails(d);
                                        }
                                    }
                                    MessageBox.Show("Data stored...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    txtFullname.Text = "";
                                    txtCNIC.Text     = "";
                                    txtAddress.Text  = "";
                                    txtMobile.Text   = "";
                                    txtRemarks.Text  = "";
                                }
                                else
                                {
                                    MessageBox.Show("Data cannot be stored...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Remarks Must be entered...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Mobile No should be selected...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Address should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("CNIC should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Full Name should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #12
0
 public int InsertCustomer(cCustomer customer)
 {
     return(new cCustomerDAL().InsertCustomer(customer));
 }
예제 #13
0
 public static Customer CreateCustomer(cCustomer Customer)
 {
     return(new Customer {
         name = Customer.Company_Name, companyID = Customer.Company_ID
     });
 }
예제 #14
0
        } // end InsertData

        /// <summary>
        /// Uses database data to create cCustomer Objects
        /// </summary>
        /// <param name="datareader">data reader containing the table data</param>
        /// <param name="retrieve">way to retrieve data</param>
        /// <returns>list of cCustomers</returns>
        private static List <cCustomer> Repackage(IDataReader datareader, retrieveCustomerData retrieve)
        {
            using (datareader)
            {
                List <cCustomer> custList = new List <cCustomer>();

                while (datareader.Read())
                {
                    cCustomer cust = cCustomer.Create();

                    switch (retrieve)
                    {
                    case retrieveCustomerData.getCustomerIdName:
                        cust.CustomerId = (int)datareader["customerId"];
                        if (datareader["name"] == DBNull.Value)
                        {
                            cust.Name = (string)datareader["contactFirstName"] + ' ' + (string)datareader["contactLastName"];
                        }
                        else
                        {
                            cust.Name = (string)datareader["name"];
                        }
                        break;

                    case retrieveCustomerData.getCustomerDetail:

                    case retrieveCustomerData.getCustomerLookup:
                        cust.CustomerId = (int)datareader["customerId"];
                        if (datareader["name"] == DBNull.Value)
                        {
                            cust.Name = (string)datareader["contactFirstName"] + ' ' + (string)datareader["contactLastName"];
                        }
                        else
                        {
                            cust.Name = (string)datareader["name"];
                        }
                        cust.ContactFirstName = (string)datareader["contactFirstName"];
                        cust.ContactLastName  = (string)datareader["contactLastName"];
                        cust.ContactNumber    = (string)datareader["contactNumber"];
                        cust.Street           = (string)datareader["street"];
                        cust.City             = (string)datareader["city"];
                        cust.Prov             = (string)datareader["prov"];
                        cust.PostalCode       = (string)datareader["postalCode"];
                        cust.CreditCheck      = (bool)datareader["creditCheck"];
                        cust.AccountNumber    = (string)datareader["accountNumber"];
                        cust.AccountType      = (string)datareader["accountType"];
                        cust.AccountExp       = (DateTime)datareader["accountExpiry"];
                        cust.AccountLimit     = (decimal)datareader["accountLimit"];
                        if (cust.CreditCheck == true)
                        {
                            cust.BankName          = (string)datareader["bankName"];
                            cust.Branch            = (string)datareader["branch"];
                            cust.BankContactName1  = (string)datareader["bankContactName1"];
                            cust.BankContactName2  = (string)datareader["bankContactName2"];
                            cust.BankContactNumber = (string)datareader["bankContactNumber"];
                            cust.BankStreet        = (string)datareader["bankStreet"];
                            cust.BankCity          = (string)datareader["bankCity"];
                            cust.BankProv          = (string)datareader["bankProv"];
                            cust.BankPostalCode    = (string)datareader["bankPostalCode"];
                        }
                        break;
                    } // end switch

                    cust.Trusted = false;
                    custList.Add(cust);
                } // end while

                datareader.Close();
                return(custList);
            } //end using
        }     // end Repackage
예제 #15
0
        } // end UpdateData

        /// <summary>
        /// Inserts a new customer record
        /// </summary>
        /// <param name="customer">the customer object to reate the record from</param>
        /// <returns>int</returns>
        public static int insertData(cCustomer customer)
        {
            int                recCount;
            string             sproc     = "insertCustomerData";
            List <ParamStruct> paramList = new List <ParamStruct>();

            ParamStruct param1 = new ParamStruct("@name", customer.Name, DbType.String, 50, ParameterDirection.Input);

            paramList.Add(param1);

            ParamStruct param2 = new ParamStruct("@contactFirstName", customer.ContactFirstName, DbType.String, 20, ParameterDirection.Input);

            paramList.Add(param2);

            ParamStruct param3 = new ParamStruct("@contactLastName", customer.ContactLastName, DbType.String, 30, ParameterDirection.Input);

            paramList.Add(param3);

            ParamStruct param4 = new ParamStruct("@contactNumber", customer.ContactNumber, DbType.String, 13, ParameterDirection.Input);

            paramList.Add(param4);

            ParamStruct param5 = new ParamStruct("@street", customer.Street, DbType.String, 30, ParameterDirection.Input);

            paramList.Add(param5);

            ParamStruct param6 = new ParamStruct("@city", customer.City, DbType.String, 20, ParameterDirection.Input);

            paramList.Add(param6);

            ParamStruct param7 = new ParamStruct("@prov", customer.Prov, DbType.String, 2, ParameterDirection.Input);

            paramList.Add(param7);

            ParamStruct param8 = new ParamStruct("@postalCode", customer.PostalCode, DbType.String, 7, ParameterDirection.Input);

            paramList.Add(param8);

            ParamStruct param9 = new ParamStruct("@creditCheck", customer.CreditCheck, DbType.Boolean, 1, ParameterDirection.Input);

            paramList.Add(param9);

            ParamStruct param10 = new ParamStruct("@accountNumber", customer.AccountNumber, DbType.String, 15, ParameterDirection.Input);

            paramList.Add(param10);

            ParamStruct param11 = new ParamStruct("@accountType", customer.AccountType, DbType.String, 15, ParameterDirection.Input);

            paramList.Add(param11);

            ParamStruct param12 = new ParamStruct("@accountExpiry", customer.AccountExp, DbType.Date, 4, ParameterDirection.Input);

            paramList.Add(param12);

            ParamStruct param13 = new ParamStruct("@accountLimit", customer.AccountLimit, DbType.Currency, 4, ParameterDirection.Input);

            paramList.Add(param13);

            if (customer.CreditCheck)
            {
                ParamStruct param14 = new ParamStruct("@bankName", customer.BankName, DbType.String, 30, ParameterDirection.Input);
                paramList.Add(param14);

                ParamStruct param15 = new ParamStruct("@branch", customer.Branch, DbType.String, 5, ParameterDirection.Input);
                paramList.Add(param15);

                ParamStruct param16 = new ParamStruct("@bankContactName1", customer.BankContactName1, DbType.String, 20, ParameterDirection.Input);
                paramList.Add(param16);

                ParamStruct param17 = new ParamStruct("@bankContactName2", customer.BankContactName2, DbType.String, 30, ParameterDirection.Input);
                paramList.Add(param17);

                ParamStruct param18 = new ParamStruct("@bankContactNumber", customer.BankContactNumber, DbType.String, 13, ParameterDirection.Input);
                paramList.Add(param18);

                ParamStruct param19 = new ParamStruct("@bankStreet", customer.BankStreet, DbType.String, 30, ParameterDirection.Input);
                paramList.Add(param19);

                ParamStruct param20 = new ParamStruct("@bankCity", customer.BankCity, DbType.String, 20, ParameterDirection.Input);
                paramList.Add(param20);

                ParamStruct param21 = new ParamStruct("@bankProv", customer.BankProv, DbType.String, 2, ParameterDirection.Input);
                paramList.Add(param21);

                ParamStruct param22 = new ParamStruct("@bankPostalCode", customer.BankPostalCode, DbType.String, 7, ParameterDirection.Input);
                paramList.Add(param22);
            }
            recCount = DAL.DAL.SendData(sproc, paramList);

            return(recCount);
        } // end InsertData
예제 #16
0
 public int UpdateCustomer(cCustomer c1)
 {
     return(new cCustomerDAL().UpdateCustomer(c1));
 }
예제 #17
0
 public int getId(cCustomer c)
 {
     return(new cCustomerDAL().getId(c));
 }