コード例 #1
0
        private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string      productID = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                Ingreadient ob        = supBLL.GetIngredientWithID(productID);
                if (ob != null)
                {
                    txtlIngredientd.Text = ob.IngredientId;
                    txtName.Text         = ob.IngredientName;
                    txtExchange.Text     = ob.IngredientExchange;
                    //txtAddress.Text = ob.SupplierAddress;
                    txtUnit.Text     = ob.IngredientUnit;
                    txtMeasure.Text  = ob.IngredientMeasure;
                    txtDonviGoc.Text = ob.IntakeUnit;
                }

                //// Xóa
                if (e.ColumnIndex == 6)
                {
                    if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaNv"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                    {
                        int Xoa = supBLL.DeleteIngredient(productID);
                        if (Xoa == 1) // xóa thành côg
                        {
                            CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaTCong"),
                                                                             Common.clsLanguages.GetResource("Information"),
                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                            dgv.Rows.RemoveAt(e.RowIndex);
                            foreach (Control c in this.pInput.Controls)
                            {
                                if (c is TextBox)
                                {
                                    ((TextBox)c).Text = String.Empty;
                                }
                                if (c is RichTextBox)
                                {
                                    ((RichTextBox)c).Text = String.Empty;
                                }
                                if (c is ComboBox)
                                {
                                    ((ComboBox)c).SelectedIndex = 0;
                                }
                                if (c is CheckBox)
                                {
                                    ((CheckBox)c).Checked = false;
                                }
                                lblTB1.Text = "...";
                                lblTB.Text  = "...";
                            }
                            DanhLaiSTT();
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: IngredientBLL.cs プロジェクト: luan-cs/API
        public int UpdateIngredient(Ingreadient employ)
        {
            /// 1: update thành công
            /// 0: Update ko thành công
            int    res      = 0;
            string queryStr = "UPDATE ingredient SET ";

            if (!string.IsNullOrEmpty(employ.IngredientName))
            {
                queryStr += string.Format(" IngredientName = '{0}',", employ.IngredientName);
            }
            //if (!string.IsNullOrEmpty(employ.Unit))
            //{
            queryStr += string.Format(" IngredientMeasure = '{0}',", employ.IngredientMeasure);
            //}
            //if (!string.IsNullOrEmpty(employ.Notes))
            //{
            queryStr += string.Format(" IngredientExchange = '{0}',", employ.IngredientExchange);
            //}
            queryStr += string.Format(" IngredientUnit = '{0}',", employ.IngredientUnit);
            queryStr += string.Format(" IntakeUnit = '{0}'", employ.IntakeUnit);

            queryStr += string.Format(" WHERE IngredientId = '{0}'", employ.IngredientId);

            Program.destopService.DataExecute(Program.Username, Program.Password, queryStr, ref errorString);

            if (string.IsNullOrEmpty(errorString))
            {
                res = 1;
            }

            return(res);
        }
コード例 #3
0
ファイル: IngredientBLL.cs プロジェクト: luan-cs/API
        public Ingreadient GetIngredientWithID(string id)
        {
            Ingreadient reEmp = new Ingreadient();
            DataSet     ds    = new DataSet();
            string      query = @"SELECT *
                            FROM `ingredient`
                            WHERE `IngredientId`='" + id + "' ";

            //Program.destopService.DataQuery(Program.Username, Program.Password, query, ref ds, "X", ref errorString);
            Program.destopService.DataQuery(Program.Username, Program.Password, query, ref ds, "X", ref errorString);
            if (string.IsNullOrEmpty(errorString) && ds.Tables[0].Rows.Count > 0)
            {
                reEmp.IngredientId       = ds.Tables[0].Rows[0]["IngredientId"].ToString();
                reEmp.IngredientName     = ds.Tables[0].Rows[0]["IngredientName"].ToString();
                reEmp.IngredientMeasure  = ds.Tables[0].Rows[0]["IngredientMeasure"].ToString();
                reEmp.IngredientExchange = ds.Tables[0].Rows[0]["IngredientExchange"].ToString();
                reEmp.IngredientUnit     = ds.Tables[0].Rows[0]["IngredientUnit"].ToString();
                reEmp.IntakeUnit         = ds.Tables[0].Rows[0]["IntakeUnit"].ToString();
            }
            else
            {
                reEmp = null;
            }

            return(reEmp);
        }
コード例 #4
0
 public frmManageIngreadient()
 {
     InitializeComponent();
     sup    = new Ingreadient();
     supSea = new Ingreadient();
     SettingControl();
     SetUIChanges();
 }
コード例 #5
0
        private void bntSeach_Click(object sender, EventArgs e)
        {
            CurPage               = 1;
            totalPage             = 1;
            supSea                = new Ingreadient();
            supSea.IngredientId   = txtlIngredientd.Text;
            supSea.IngredientName = txtName.Text;
            //supSea.SupplierAddress = txtAddress.Text;
            supSea.IngredientMeasure  = txtMeasure.Text;
            supSea.IngredientExchange = txtExchange.Text;
            supSea.IngredientUnit     = txtUnit.Text;

            SearchProducts(1);
        }
コード例 #6
0
ファイル: IngredientBLL.cs プロジェクト: luan-cs/API
        public DataTable SearchIngredient(Ingreadient sup, int page, out int TotalRecord)
        {
            int RecordPerPage = int.Parse(ConfigurationManager.AppSettings["MaxRecordDesk"]);
            int limit         = (page - 1) * RecordPerPage;

            //int offset = limit + RecordPerPage;
            TotalRecord = 0;
            DataTable res = new DataTable();
            DataSet   ds  = new DataSet();

            ///p_CreateBy	VARCHAR(20),
            //p_CreatedDate	DATETIME,
            //p_ModifiedBy	VARCHAR(20), p_SupplierId       VARCHAR(20)  ,
            string[][] param =
            {
                new string[] { "p_IngredientId",       string.IsNullOrEmpty(sup.IngredientId)?null:sup.IngredientId              },
                new string[] { "p_IngredientName",     string.IsNullOrEmpty(sup.IngredientName)?null:sup.IngredientName          },
                new string[] { "p_IngredientMeasure",  string.IsNullOrEmpty(sup.IngredientMeasure)?null: sup.IngredientMeasure   },
                new string[] { "p_IngredientExchange", string.IsNullOrEmpty(sup.IngredientExchange)?null: sup.IngredientExchange },
                new string[] { "p_IngredientUnit",     string.IsNullOrEmpty(sup.IngredientUnit)?null: sup.IngredientUnit         },
                new string[] { "p_NoStart",            limit.ToString()                                                          },
                new string[] { "p_NoEnd",              RecordPerPage.ToString()                                                  }
            };

            Program.destopService.DataStoreProcQuery_Param(Program.Username, Program.Password, "spSearch_Ingredients", ref ds, param, ref errorString);

            if (string.IsNullOrEmpty(errorString))
            {
                res         = ds.Tables[0];
                TotalRecord = int.Parse(ds.Tables[1].Rows[0][0].ToString());
            }
            else
            {
                res = null;
            }

            return(res);
        }
コード例 #7
0
        private void SaveData()
        {
            // check xem có trong db chưa?
            string      SupplierID = txtlIngredientd.Text.Trim();
            Ingreadient pro        = new Ingreadient();

            pro = supBLL.GetIngredientWithID(SupplierID);

            supSea = new Ingreadient();

            supSea.IngredientName = txtName.Text;
            //supSea.SupplierAddress = txtAddress.Text;
            supSea.IngredientMeasure  = txtMeasure.Text;
            supSea.IngredientExchange = txtExchange.Text;
            supSea.IngredientUnit     = txtUnit.Text;
            supSea.IntakeUnit         = txtDonviGoc.Text;


            if (pro != null)
            {// Cập nhật
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeUpdate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    supSea.IngredientId = SupplierID;
                    int i = supBLL.UpdateIngredient(supSea);
                    if (i == 1)
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateSuccess1");
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateNoSuccess1");
                    }
                }
            }
            else
            {// Thêm mới
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeCreate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    SupplierID          = supBLL.CreateSupplierId();
                    supSea.IngredientId = SupplierID;

                    int i = supBLL.InsertIngredient(supSea);
                    if (i == 1)
                    {
                        lblTB1.Text          = Common.clsLanguages.GetResource("InsertSuccess1");
                        txtlIngredientd.Text = SupplierID;
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("InsertNoSuccess1");
                    }
                }
            }

            SearchProducts(1);
        }
コード例 #8
0
ファイル: IngredientBLL.cs プロジェクト: luan-cs/API
        public int InsertIngredient(Ingreadient employ)
        {
            /// 1: update thành công
            /// 0: Update ko thành công

            int    res      = 0;
            string queryStr = "INSERT INTO";

            queryStr += " ingredient (";
            if (!string.IsNullOrEmpty(employ.IngredientId))
            {
                queryStr += "`IngredientId`,";
            }
            if (!string.IsNullOrEmpty(employ.IngredientName))
            {
                queryStr += "`IngredientName`,";
            }
            if (!string.IsNullOrEmpty(employ.IngredientMeasure))
            {
                queryStr += "`IngredientMeasure`,";
            }
            if (!string.IsNullOrEmpty(employ.IngredientExchange))
            {
                queryStr += "`IngredientExchange`,";
            }
            if (!string.IsNullOrEmpty(employ.IngredientUnit))
            {
                queryStr += "`IngredientUnit`,";
            }
            queryStr += "`IntakeUnit`";

            queryStr += ") VALUES (";

            if (!string.IsNullOrEmpty(employ.IngredientId))
            {
                queryStr += string.Format("'{0}',", employ.IngredientId);
            }
            if (!string.IsNullOrEmpty(employ.IngredientName))
            {
                queryStr += string.Format("'{0}',", employ.IngredientName);
            }
            if (!string.IsNullOrEmpty(employ.IngredientMeasure))
            {
                queryStr += string.Format("'{0}',", employ.IngredientMeasure);
            }
            if (!string.IsNullOrEmpty(employ.IngredientExchange))
            {
                queryStr += string.Format("'{0}',", employ.IngredientExchange);
            }
            if (!string.IsNullOrEmpty(employ.IngredientUnit))
            {
                queryStr += string.Format("'{0}',", employ.IngredientUnit);
            }
            queryStr += string.Format("'{0}'", employ.IntakeUnit);
            queryStr += ")";
            Program.destopService.DataExecute(Program.Username, Program.Password, queryStr, ref errorString);
            if (string.IsNullOrEmpty(errorString))
            {
                res = 1;
            }
            return(res);
        }