public static INProduct ConvertToInfo(DataRow dr)
        {
            INProduct _inproduct = new INProduct();
            _inproduct.ProductID = dr["ProductID"].ToString();
            _inproduct.Descr = dr["Descr"].ToString();
            _inproduct.ClassID1 = dr["ClassID1"].ToString();
            _inproduct.ClassID2 = dr["ClassID2"].ToString();
            _inproduct.VendID = dr["VendID"].ToString();
            _inproduct.Status = dr["Status"].ToString();
            _inproduct.FromUnit = dr["FromUnit"].ToString();
            _inproduct.ToUnit = dr["ToUnit"].ToString();
            _inproduct.Cnvfact = float.Parse(dr["Cnvfact"].ToString());
            _inproduct.POFromUnitPrice = float.Parse(dr["POFromUnitPrice"].ToString());
            _inproduct.POToUnitPrice = float.Parse(dr["POToUnitPrice"].ToString());
            if (dr["POPriEffDate"].ToString()!= "")
                _inproduct.POPriEffDate = DateTime.Parse(dr["POPriEffDate"].ToString());

            _inproduct.SOFromUnitPrice = float.Parse(dr["SOFromUnitPrice"].ToString());
            _inproduct.SOToUnitPrice = float.Parse(dr["SOToUnitPrice"].ToString());
            _inproduct.POUnit = dr["POUnit"].ToString();
            _inproduct.SOUnit = dr["SOUnit"].ToString();
            _inproduct.INUnit = dr["INUnit"].ToString();
            _inproduct.Color = dr["Color"].ToString();
            _inproduct.DfltWhID = dr["DfltWhID"].ToString();
            _inproduct.Picture = dr["Picture"].ToString();
            _inproduct.Size = dr["Size"].ToString();
            _inproduct.Volume = float.Parse(dr["Volume"].ToString());
            _inproduct.Weight = float.Parse(dr["Weight"].ToString());
            _inproduct.Style = dr["Style"].ToString();
            _inproduct.TaxID = dr["TaxID"].ToString();
            _inproduct.Crtd_DateTime = DateTime.Parse(dr["Crtd_DateTime"].ToString());
            _inproduct.Crtd_Prog = dr["Crtd_Prog"].ToString();
            _inproduct.Crtd_User = dr["Crtd_User"].ToString();
            return _inproduct;
        }
Esempio n. 2
0
        private INProduct _GetProduct(string _productID)
        {
            INProduct _info = new INProduct();
            DataRow[] _dr = null;
            _dr = _dtINProduct.Select(string.Format("ProductID = '{0}'", _productID));

            if (_dr.Length > 0)
                _info = IN106Ctrl.ConvertToInfo(_dr[0]);
            else
                _info = null;
            return _info;
        }
Esempio n. 3
0
        private INProduct _GetProduct(int _row)
        {
            INProduct _info = new INProduct();
            _info.ProductID = dgv.Rows[_row].Cells["ProductID"].Value.ToString().Trim();
            _info.Descr = dgv.Rows[_row].Cells["Descr"].Value.ToString();
            _info.ClassID1 = dgv.Rows[_row].Cells["ClassID1"].Value.ToString();
            _info.ClassID2 = dgv.Rows[_row].Cells["ClassID2"].Value.ToString();
            _info.VendID = dgv.Rows[_row].Cells["VendID"].Value.ToString();
            _info.Status = dgv.Rows[_row].Cells["Status"].Value.ToString();
            _info.FromUnit = dgv.Rows[_row].Cells["FromUnit"].Value.ToString();
            _info.ToUnit = dgv.Rows[_row].Cells["ToUnit"].Value.ToString();
            _info.Cnvfact = double.Parse(dgv.Rows[_row].Cells["Cnvfact"].Value.ToString());
            _info.POFromUnitPrice = double.Parse(dgv.Rows[_row].Cells["POFromUnitPrice"].Value.ToString());
            _info.POToUnitPrice = double.Parse(dgv.Rows[_row].Cells["POToUnitPrice"].Value.ToString());
            if (dgv.Rows[_row].Cells["POPriEffDate"].Value.ToString() != "")
                _info.POPriEffDate = DateTime.Parse(dgv.Rows[_row].Cells["POPriEffDate"].Value.ToString());
            if (dgv.Rows[_row].Cells["SOPriEffDate"].Value.ToString() != "")
                _info.SOPriEffDate = DateTime.Parse(dgv.Rows[_row].Cells["SOPriEffDate"].Value.ToString());
            _info.SOFromUnitPrice = double.Parse(dgv.Rows[_row].Cells["SOFromUnitPrice"].Value.ToString());
            _info.SOToUnitPrice = double.Parse(dgv.Rows[_row].Cells["SOToUnitPrice"].Value.ToString());
            _info.POUnit = dgv.Rows[_row].Cells["POUnit"].Value.ToString();
            _info.SOUnit = dgv.Rows[_row].Cells["SOUnit"].Value.ToString();
            _info.INUnit = dgv.Rows[_row].Cells["INUnit"].Value.ToString();
            _info.Color = dgv.Rows[_row].Cells["Color"].Value.ToString();
            _info.DfltWhID = dgv.Rows[_row].Cells["DfltWhID"].Value.ToString();
            _info.Picture = dgv.Rows[_row].Cells["Picture"].Value.ToString();
            _info.Size = dgv.Rows[_row].Cells["Size"].Value.ToString();
            _info.Volume = double.Parse(dgv.Rows[_row].Cells["Volume"].Value.ToString());
            _info.Weight = double.Parse(dgv.Rows[_row].Cells["Weight"].Value.ToString());
            _info.Style = dgv.Rows[_row].Cells["Style"].Value.ToString();
            _info.TaxID = dgv.Rows[_row].Cells["TaxID"].Value.ToString();
            _info.Crtd_DateTime = DateTime.Parse(dgv.Rows[_row].Cells["Crtd_DateTime"].Value.ToString());
            _info.Crtd_Prog = dgv.Rows[_row].Cells["Crtd_Prog"].Value.ToString(); ;
            _info.Crtd_User = dgv.Rows[_row].Cells["Crtd_User"].Value.ToString(); ;
            _info.LUpd_DateTime = DateTime.Parse(dgv.Rows[_row].Cells["LUpd_DateTime"].Value.ToString());
            _info.LUpd_Prog = dgv.Rows[_row].Cells["LUpd_Prog"].Value.ToString(); ;
            _info.LUpd_User = dgv.Rows[_row].Cells["LUpd_User"].Value.ToString(); ;

            return _info;
        }
Esempio n. 4
0
        private INProduct _GetPanel()
        {
            INProduct info = new INProduct();
            info.ProductID = txtProductID.Text.Trim();
            info.Descr = txtDesc.Text.Trim();
            info.ClassID1 = txtClassID1.Text.Trim();
            info.ClassID2 = txtClassID2.Text.Trim();
            info.VendID = txtVendID.Text.Trim();
            if (chkStatus.Checked == true)
                info.Status = "1";
            else
                info.Status = "0";

            if (txtFromUnit.SelectedValue == null)
                info.FromUnit = "";
            else
                info.FromUnit = txtFromUnit.SelectedValue.ToString();
            if (txtToUnit.SelectedValue == null)
                info.ToUnit = "";
            else
                info.ToUnit = txtToUnit.SelectedValue.ToString();

            if (txtCnvfact.Text.Trim() != "")
                info.Cnvfact = double.Parse(txtCnvfact.Text.Trim());
            if (txtPOFromUnitPrice.Text.Trim() != "")
                info.POFromUnitPrice = double.Parse(txtPOFromUnitPrice.Text.Trim());
            if (txtPOToUnitPrice.Text.Trim() != "")
                info.POToUnitPrice = double.Parse(txtPOToUnitPrice.Text.Trim());
            if (txtSOFromUnitPrice.Text.Trim() != "")
                info.SOFromUnitPrice = double.Parse(txtSOFromUnitPrice.Text.Trim());
            if (txtSOToUnitPrice.Text.Trim() != "")
                info.SOToUnitPrice = double.Parse(txtSOToUnitPrice.Text.Trim());
            info.POPriEffDate = dtiPOPriEffDate.Value;
            info.SOPriEffDate = dtiSOPriEffDate.Value;

            if (txtPOUnit.SelectedValue == null)
                info.POUnit = "";
            else
                info.POUnit = txtPOUnit.SelectedValue.ToString();
            if (txtSOUnit.SelectedValue == null)
                info.SOUnit = "";
            else
                info.SOUnit = txtSOUnit.SelectedValue.ToString();
            if (txtINUnit.SelectedValue == null)
                info.INUnit = "";
            else
                info.INUnit = txtINUnit.SelectedValue.ToString();
            if (txtDfltWhID.SelectedValue == null)
                info.DfltWhID = "";
            else
                info.DfltWhID = txtDfltWhID.SelectedValue.ToString();
            info.Color = txtColor.Text.Trim();
            info.Picture = txtPicture.Text.Trim();
            info.Size = txtSize.Text.Trim();
            if (txtVolume.Text.Trim() != "")
                info.Volume = double.Parse(txtVolume.Text.Trim());
            if (txtWeight.Text.Trim() != "")
                info.Weight = double.Parse(txtWeight.Text.Trim());
            info.Style = txtStyle.Text.Trim();
            info.TaxID = txtTaxID.SelectedValue.ToString();
            info.Crtd_DateTime = dtiCrtd_DateTime.Value;
            info.Crtd_Prog = txtCrtd_Prog.Text.Trim();
            info.Crtd_User = txtCrtd_User.Text.Trim();
            info.LUpd_DateTime = DateTime.Now;
            info.LUpd_Prog = _strPro;
            info.LUpd_User = Globals.PTUserName;
            return info;
        }
Esempio n. 5
0
 private void btnCopy_Click(object sender, EventArgs e)
 {
     string copy = txtCopy.Text.Trim();
     string proid = txtProductID.Text.Trim();
     if (copy == "")
     {
         Utility.MessageShow("001", Globals.PTLanguage, "ProductID");
         txtCopy.Focus();
         return;
     }
     if (_dtINProduct.Rows.Count > 0)
     {
         DataRow[] dr = _dtINProduct.Select(string.Format("ProductID = '{0}'", copy));
         if (dr.Count() <= 0)
         {
             MessageBox.Show("ProductID khong ton tai", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtCopy.Focus();
             txtCopy.SelectionStart = 0;
             txtCopy.SelectionLength = copy.Length;
             return;
         }
         else
         {
             INProduct p = new INProduct();
             p = _GetProduct(copy);
             _AddToPanel(p);
             _BindDataToPanel();
             dgv.Visible = false;
             pnl.Visible = true;
             txtProductID.Enabled = true;
             txtProductID.Text = copy + "-1";
             txtProductID.Focus();
             txtProductID.SelectionStart = 0;
             txtProductID.SelectionLength = txtProductID.Text.Length; ;
         }
     }
 }
Esempio n. 6
0
        private void _AddToPanel(INProduct _info)
        {
            if (_info != null)
            {
                txtProductID.Text = _info.ProductID.ToString();
                txtDesc.Text = _info.Descr.ToString();
                txtClassID1.Text = _info.ClassID1.ToString();
                txtClassID2.Text = _info.ClassID2.ToString();
                txtVendID.SelectedValue = _info.VendID.ToString();

                if (_info.Status == "True")
                    chkStatus.Checked = true;
                else
                    chkStatus.Checked = false;
                //cbxStatus.Text = _info.Status.ToString();

                txtFromUnit.SelectedValue = _info.FromUnit.ToString();
                txtToUnit.SelectedValue = _info.ToUnit.ToString();
                _BindUnit();
                txtCnvfact.Text = _info.Cnvfact.ToString();
                txtPOFromUnitPrice.Text = _info.POFromUnitPrice.ToString();
                txtPOToUnitPrice.Text = _info.POToUnitPrice.ToString();
                if (_info.POPriEffDate.ToString() != "")
                    dtiPOPriEffDate.Value = _info.POPriEffDate;
                txtSOFromUnitPrice.Text = _info.SOFromUnitPrice.ToString();
                txtSOToUnitPrice.Text = _info.SOToUnitPrice.ToString();
                if (_info.SOPriEffDate.ToString() != "")
                    dtiSOPriEffDate.Value = _info.SOPriEffDate;
                txtPOUnit.SelectedValue = _info.POUnit.ToString();
                txtSOUnit.SelectedValue = _info.SOUnit.ToString();
                txtINUnit.SelectedValue = _info.INUnit.ToString();
                txtColor.Text = _info.Color.ToString();
                txtDfltWhID.SelectedValue = _info.DfltWhID.ToString();
                txtPicture.Text = _info.Picture.ToString();
                txtSize.Text = _info.Size.ToString();
                txtVolume.Text = _info.Volume.ToString();
                txtWeight.Text = _info.Weight.ToString();
                txtStyle.Text = _info.Style.ToString();
                txtTaxID.SelectedValue = _info.TaxID.ToString();
                txtProductID.Text = _info.ProductID;
                txtProductID.Enabled = false;
                if (_info.Crtd_DateTime.ToString() == "")
                    dtiCrtd_DateTime.Value = DateTime.Now;
                else
                    dtiCrtd_DateTime.Value = _info.Crtd_DateTime;
                txtCrtd_Prog.Text = _info.Crtd_Prog.ToString();
                txtCrtd_User.Text = _info.Crtd_User.ToString();
            }
        }
Esempio n. 7
0
 private void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     pnldgv.Visible = false;
     pnl.Visible = false;
     pnl.Dock = DockStyle.Fill;
     pnldgv.Dock = DockStyle.Fill;
     INProduct _info = new INProduct();
     _info = _GetProduct(e.RowIndex);
     _BindDataToPanel();
     _AddToPanel(_info);
     _strStage = 1;
     txtCopy.Enabled = false;
     btnCopy.Enabled = false;
     btnSave.Enabled = true;
     btnDelete.Enabled = true;
     btnBack.Enabled = true;
     pnl.Visible = true;
 }
Esempio n. 8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgv.Visible == true)
            {
                Int32 _intTotalRow = dgv.Rows.GetRowCount(DataGridViewElementStates.Selected);
                if (_intTotalRow > 0)
                {
                    if (MessageBox.Show("Bạn có muốn xóa '" + _intTotalRow +
                                        "' dòng được chọn không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        for (int i = 0; i < _intTotalRow; i++)
                        {
                            int _row = Int16.Parse(dgv.SelectedRows[i].Index.ToString());
                            _DeleteRow(_row);
                        }
                        _BindGrid();
                    }

                }
            }
            else if (pnl.Visible == true)
            {
                string _strProductID = txtProductID.Text.Trim();

                if (IN106Ctrl.CheckProductUsed(_strProductID) == false)
                {
                    int _row1 = _GetProductRow(_strProductID);
                    if (_row1 == -1)
                        return;
                    if (MessageBox.Show("Mã sản phẩm: '" + _strProductID +
                                        "' không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        int _row = _GetProductRow(_strProductID);
                        INProduct _INProduct = new INProduct();
                        _INProduct = _GetProduct(_row + 1);
                        _DeleteRow(_strProductID);
                        _BindGrid();
                        _RefreshPanel();
                        _AddToPanel(_INProduct);

                    }
                }
                else
                    MessageBox.Show("Mã sản phẩm: " + _strProductID +
                                    " đang được dùng, bạn không thể xóa được.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static int SaveProduct( INProduct info)
        {
            SqlDateTime strPOPriEffDate;
            if (info.POPriEffDate.ToString() == "1/1/0001 12:00:00 AM")
                strPOPriEffDate = SqlDateTime.Null;
            else
                strPOPriEffDate = info.POPriEffDate;
            SqlDateTime strSOPriEffDate;
            if (info.SOPriEffDate.ToString() == "1/1/0001 12:00:00 AM")
                strSOPriEffDate = SqlDateTime.Null;
            else
                strSOPriEffDate = info.SOPriEffDate;

            return ConnectDB.ExecuteScalar("sp_ProductSave",
                new String[] { "ProductID" ,"Descr","ClassID2" ,"ClassID1" ,"VendID" ,"Status" ,
                                "FromUnit" ,"ToUnit" ,"Cnvfact" ,"POFromUnitPrice" ,"POToUnitPrice" ,"POPriEffDate" ,
                                "SOFromUnitPrice" ,"SOToUnitPrice" ,"SOPriEffDate" ,"POUnit" ,"SOUnit" ,"INUnit" ,
                                "Color" ,"DfltWhID" ,"Picture" ,"Size" ,"Volume" ,"Weight" ,
                                "Style" ,"TaxID" ,"Crtd_DateTime" ,"Crtd_Prog" ,"Crtd_User" ,
                                "LUpd_DateTime" ,"LUpd_Prog" ,"LUpd_User"},
                new Object[] { info.ProductID, info.Descr, info.ClassID2, info.ClassID1, info.VendID, info.Status,
                               info.FromUnit, info.ToUnit, info.Cnvfact, info.POFromUnitPrice, info.POToUnitPrice,strPOPriEffDate,
                               info.SOFromUnitPrice,info.SOToUnitPrice,strSOPriEffDate,info.POUnit,info.SOUnit,info.INUnit,
                               info.Color,info.DfltWhID,info.Picture,info.Size,info.Volume,info.Weight,
                               info.Style,info.TaxID,info.Crtd_DateTime,info.Crtd_Prog,info.Crtd_User,
                               info.LUpd_DateTime,info.LUpd_Prog,info.LUpd_User});
        }