Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                byte[] Picture;
                if (pbox.Image == null)
                {
                    Picture = new byte[0];
                    cust.ADD_CUSTOMER(txtFirstName.Text, txtLastName.Text, txtTel.Text, txtEmail.Text, Picture, "without_image", CustName.Text, CustPass.Text);
                    MessageBox.Show("تمت الإضافة بنجاح", "الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.dgList.DataSource = cust.GET_ALL_CUSTOMERS();
                    CustName.ReadOnly      = true;
                    CustPass.ReadOnly      = true;
                    txtTel.ReadOnly        = true;
                    txtEmail.ReadOnly      = true;
                    txtFirstName.ReadOnly  = true;
                    txtLastName.ReadOnly   = true;
                    CustName.Clear();
                    CustPass.Clear();
                    txtFirstName.Clear();
                    txtLastName.Clear();
                    txtTel.Clear();
                    txtEmail.Clear();
                }

                else
                {
                    MemoryStream ms = new MemoryStream();
                    pbox.Image.Save(ms, pbox.Image.RawFormat);
                    Picture = ms.ToArray();
                    cust.ADD_CUSTOMER(txtFirstName.Text, txtLastName.Text, txtTel.Text, txtEmail.Text, Picture, "with_image", CustName.Text, CustPass.Text);
                    MessageBox.Show("تمت الإضافة بنجاح", "الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.dgList.DataSource = cust.GET_ALL_CUSTOMERS();
                    CustName.ReadOnly      = true;
                    CustPass.ReadOnly      = true;
                    txtTel.ReadOnly        = true;
                    txtEmail.ReadOnly      = true;
                    txtFirstName.ReadOnly  = true;
                    txtLastName.ReadOnly   = true;
                    CustName.Clear();
                    CustPass.Clear();
                    txtFirstName.Clear();
                    txtLastName.Clear();
                    txtTel.Clear();
                    txtEmail.Clear();
                }
            }
            catch
            {
                return;
            }
            finally
            {
                btnAdd.Enabled    = false;
                btnNew.Enabled    = true;
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
                button1.Enabled   = true;
            }
        }
Example #2
0
 private void Clear_Click(object sender, EventArgs e)
 {
     //Clear all the textboxes
     PhoneNo.Clear();
     Address.Clear();
     Email.Clear();
     CustName.Clear();
     CustomerName.Clear();
     CustID.Clear();
 }
Example #3
0
 private void Cancel_Click(object sender, RoutedEventArgs e)
 {
     CustName.Clear();
     InvoiceNo.Clear();
     OrderNo.Clear();
     InvoiceDate.Clear();
     DueDate.Clear();
     SubTotal.Clear();
     Adjustment.Clear();
     Total.Clear();
     CustNotes.Clear();
     TermAndCondns.Clear();
 }
Example #4
0
 private void Cancel_Click(object sender, RoutedEventArgs e)
 {
     CustName.Clear();
     SalesOrderNo.Clear();
     ReferenceNo.Clear();
     SalesOrderDate.Clear();
     ShipmentDate.Clear();
     SubTotal.Clear();
     Adjustment.Clear();
     Total.Clear();
     CustNotes.Clear();
     TermAndCondns.Clear();
 }
 protected void TxtFMemName_TextChanged(object sender, EventArgs e)
 {
     try
     {
         CustName = TxtFMemName.Text.ToString();
         string[] custnob = CustName.Split('_');
         if (custnob.Length > 1)
         {
             TxtFMemName.Text = custnob[0].ToString();
             TxtFMemNo.Text   = (string.IsNullOrEmpty(custnob[1].ToString()) ? "" : custnob[1].ToString());
         }
     }
     catch (Exception Ex)
     {
         ExceptionLogging.SendErrorToText(Ex);
     }
 }
 private void clear_Click(object sender, EventArgs e)
 {
     Cust_search.Clear();
     CustName.Clear();
     PhoneNumber.Clear();
     Cust_address.Clear();
     custEmail.Clear();
     Product_search.Clear();
     Product_Name.Clear();
     ProductID.Clear();
     Total_Amt.Text = "0";
     SubTotal.Clear();
     Discount.Text = "0";
     GST.Clear();
     PaidAmount.Clear();
     ReturnAmount.Clear();
     Quantity.Text            = "0";
     Amount.Text              = "0";
     AddedProducts.DataSource = null;
 }
Example #7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (ID == 0)
     {
         MessageBox.Show("يرجئ تحديد العميل");
         return;
     }
     if (MessageBox.Show("هل تريد حذف هذا العميل؟", "الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         cust.DELETE_CUSTOMER(ID);
         MessageBox.Show("تم الحذف بنجاح", "الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information);
         CustName.Clear();
         CustPass.Clear();
         txtTel.Clear();
         txtEmail.Clear();
         pbox.Image = null;
         txtFirstName.Clear();
         txtLastName.Clear();
         this.dgList.DataSource = cust.GET_ALL_CUSTOMERS();
     }
 }
        private void Cust_search_TextChanged(object sender, EventArgs e)
        {
            String keyword = Cust_search.Text;

            if (keyword == "")
            {
                Cust_search.Clear();
                CustName.Clear();
                PhoneNumber.Clear();
                Cust_address.Clear();
                custEmail.Clear();
                return;
            }

            Connect connectObj = new Connect();

            con = connectObj.connect();
            DataTable dt = new DataTable();


            try
            {
                String         sql  = "SELECT CNAME,ADDRESS,PHONE_NUMBER,EMAIL,C_ID FROM CUSTOMER WHERE C_ID LIKE '%" + keyword + "%' OR CNAME LIKE '%" + keyword + "%';";
                SqlDataAdapter adpt = new SqlDataAdapter(sql, con);

                adpt.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    CustName.Text     = dt.Rows[0]["CNAME"].ToString();
                    PhoneNumber.Text  = dt.Rows[0]["PHONE_NUMBER"].ToString();
                    Cust_address.Text = dt.Rows[0]["ADDRESS"].ToString();
                    custEmail.Text    = dt.Rows[0]["EMAIL"].ToString();
                    cid = dt.Rows[0]["C_ID"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            CustName.Clear();
            CustPass.Clear();
            txtFirstName.Clear();
            txtLastName.Clear();
            txtTel.Clear();
            txtEmail.Clear();

            CustName.Focus();
            btnAdd.Enabled        = true;
            btnNew.Enabled        = false;
            btnEdit.Enabled       = false;
            btnDelete.Enabled     = false;
            button1.Enabled       = false;
            txtFirstName.ReadOnly = false;
            txtLastName.ReadOnly  = false;
            txtTel.ReadOnly       = false;
            txtEmail.ReadOnly     = false;
            CustName.ReadOnly     = false;
            CustPass.ReadOnly     = false;
        }
Example #10
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     CustName.Focus();
 }
Example #11
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            WFilter wf = new WFilter(1, "CustName", true);

            wf.tableName = "T_CustomerInf";    //表名
            wf.strSql    = "select CustID as 客户编号, CustName as 客户名称, CustType as 类别,City as 城市地区,communicateAddr as 通信地址, CredDegree as 信用等级,T_CustomerImp.importance as 客户重要度 " +
                           " from T_CustomerInf left join T_CustomerImp " +
                           " on T_CustomerInf.ImportanceDegreeId= T_CustomerImp.Iid";

            wf.s_items.Add("客户编号,CustID,C");
            wf.s_items.Add("客户名称,CustName,C");
            wf.s_items.Add("类别,CustType,C");
            wf.s_items.Add("城市地区,City,C");
            wf.s_items.Add("重要度,importance,C");
            wf.ShowDialog();

            if (wf.DialogResult == DialogResult.OK)
            {
                //插入
                List <string> sqls   = new List <string>();
                DBUtil        dbUtil = new DBUtil();
                string        custId = this.custid;

                foreach (string CustName in wf.Return_Items)
                {
                    string parentcustId = dbUtil.Get_Single_val("T_CustomerInf", "CustID", "CustName", CustName.Trim());
                    if (parentcustId == "")
                    {
                        return;
                    }

                    //插入前判断
                    string strSqlSel = "select * from T_Customer_Rela where CustID='{0}' and ParentID='{1}'";
                    strSqlSel = string.Format(strSqlSel, custId, parentcustId);
                    bool isExit = dbUtil.yn_exist_data(strSqlSel);

                    if (isExit == true)
                    {
                        return;
                    }

                    string strSql = "insert into T_Customer_Rela(CustID,ParentID) values('{0}','{1}')";
                    strSql = string.Format(strSql, custId, parentcustId);
                    sqls.Add(strSql);
                }
                (new SqlDBConnect()).Exec_Tansaction(sqls);

                InitDataGridView();
            }
        }
        private void Save_Click(object sender, EventArgs e)
        {
            //Create the orders
            try
            {
                Connect connectObj = new Connect();
                con = connectObj.connect();
                SqlCommand cmd = new SqlCommand("Insert into MYORDER (ORD_ID,CID,DATE,AMOUNT) values(@oid,@cid,@date,@amount);", con);

                cmd.Parameters.AddWithValue("@oid", OrderID.Text);
                //cmd.Parameters.AddWithValue("@pid", textBox8.Text);
                cmd.Parameters.AddWithValue("@cid", cid);
                cmd.Parameters.AddWithValue("@date", date.Text);
                cmd.Parameters.AddWithValue("@amount", Total_Amt.Text);

                int i = cmd.ExecuteNonQuery();
                //If count is equal to 1, than show frmMain form
                if (i != 0)
                {
                    MessageBox.Show("Order Insertion Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Order Insertion Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            //Insert into orderDetails
            try
            {
                int j;

                Connect connectObj = new Connect();
                con = connectObj.connect();


                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    SqlCommand cmd = new SqlCommand("Insert into ORDER_DETAILS (ord_id,pid,quantity) values(@oid,@pid,@quantity);", con);

                    cmd.Parameters.AddWithValue("@oid", OrderID.Text);
                    cmd.Parameters.AddWithValue("@pid", transactionDT.Rows[i]["Product ID"].ToString());
                    cmd.Parameters.AddWithValue("@quantity", transactionDT.Rows[i]["Quantity"].ToString());


                    j = cmd.ExecuteNonQuery();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            //Update stock table after creating order
            try
            {
                int     j;
                Connect connectObj = new Connect();
                con = connectObj.connect();

                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    SqlCommand cmd = new SqlCommand("UPDATE STOCK SET QUANTITY = QUANTITY - @quantity WHERE PID = @pid", con);

                    cmd.Parameters.AddWithValue("@pid", transactionDT.Rows[i]["Product ID"].ToString());
                    cmd.Parameters.AddWithValue("@quantity", transactionDT.Rows[i]["Quantity"].ToString());


                    j = cmd.ExecuteNonQuery();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }

            //Clear all the fields.
            Cust_search.Clear();
            CustName.Clear();
            PhoneNumber.Clear();
            Cust_address.Clear();
            custEmail.Clear();
            Product_search.Clear();
            Product_Name.Clear();
            ProductID.Clear();
            Total_Amt.Text = "0";
            SubTotal.Clear();
            Discount.Text = "0";
            GST.Clear();
            PaidAmount.Clear();
            ReturnAmount.Clear();
            Quantity.Text            = "0";
            Amount.Text              = "0";
            AddedProducts.DataSource = null;
        }