Beispiel #1
0
        private void LoadTable()
        {
            // Đoạn này quan trọng. Đăng nhập bằng user nào => connectionString tương ứng
            this.taNV.Connection.ConnectionString             =
                this.taDH.Connection.ConnectionString         =
                    this.taPN.Connection.ConnectionString     =
                        this.taPX.Connection.ConnectionString =
                            UtilDB.ConnectionString;
            try
            {
                this.dataSet.EnforceConstraints = false;

                // TODO: This line of code loads data into the 'dataSet.NhanVien' table. You can move, or remove it, as needed.
                this.taNV.Fill(this.dataSet.NhanVien);

                // TODO: This line of code loads data into the 'dataSet.DatHang' table. You can move, or remove it, as needed.
                this.taDH.Fill(this.dataSet.DatHang);

                // TODO: This line of code loads data into the 'dataSet.PhieuXuat' table. You can move, or remove it, as needed.
                this.taPX.Fill(this.dataSet.PhieuXuat);

                // TODO: This line of code loads data into the 'dataSet.PhieuNhap' table. You can move, or remove it, as needed.
                this.taPN.Fill(this.dataSet.PhieuNhap);

                //this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #2
0
        private void LoadTable()
        {
            // Đoạn này quan trọng. Đăng nhập bằng user nào => connectionString tương ứng
            this.taDDH.Connection.ConnectionString                          =
                this.taCTDDH.Connection.ConnectionString                    =
                    this.taDSVT.Connection.ConnectionString                 =
                        this.taDSKHO.Connection.ConnectionString            =
                            this.taDSNCC.Connection.ConnectionString        =
                                this.taDSNV.Connection.ConnectionString     =
                                    this.taDSVT.Connection.ConnectionString =
                                        UtilDB.ConnectionString;
            try
            {
                this.dataSet.EnforceConstraints = false;
                this.taDDH.Fill(this.dataSet.DatHang);
                this.taCTDDH.Fill(this.dataSet.CTDDH);
                this.taDSVT.Fill(this.dataSet.DSVT);
                this.taDSNCC.Fill(this.dataSet.DSNCC);
                this.taDSNV.Fill(this.dataSet.DSNV);
                this.taDSKHO.Fill(this.dataSet.DSKHO);
                this.taDSVT.Fill(this.dataSet.DSVT);

                //this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
        private async Task <bool> SwitchDepartment(int oldId, string newDepartment)
        {
            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(MyConfig.SpChuyenChiNhanh, connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@manv", oldId);
                    command.Parameters.AddWithValue("@chinhanhmoi", newDepartment);

                    try
                    {
                        await command.ExecuteNonQueryAsync();

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                        return(false);
                    }
                }
            }
        }
        private void LoadTable()
        {
            // Đoạn này quan trọng. Đăng nhập bằng user nào => connectionString tương ứng
            this.taPX.Connection.ConnectionString                     =
                this.taDSNV.Connection.ConnectionString               =
                    this.taCTPX.Connection.ConnectionString           =
                        this.taDSKHO.Connection.ConnectionString      =
                            this.taDSVTCH.Connection.ConnectionString =
                                UtilDB.ConnectionString;
            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taPX.Fill(this.dataSet.PhieuXuat);

                this.taCTPX.Fill(this.dataSet.CTPX);

                this.taDSNV.Fill(this.dataSet.DSNV);

                this.taDSKHO.Fill(this.dataSet.DSKHO);

                this.taDSVTCH.Fill(this.dataSet.DSVTCONHANG);

                //this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #5
0
        private bool chechInStockMaterials(string maPhieu, string maVattu, int quantity)
        {
            bool   exist   = true;
            string strLenh = string.Format(MyConfig.ExecSPCheckInStockMaterial, maPhieu, maVattu, quantity);

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand sqlcmd = new SqlCommand(strLenh, connection))
                {
                    sqlcmd.CommandType = CommandType.Text;
                    try
                    {
                        sqlcmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == MyConfig.ErrorMsgNumNotExistObject)
                        {
                            exist = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                    }
                }
            }
            return(exist);
        }
Beispiel #6
0
        public Xrpt_ReportHDNV(string tenCN, string tenNV, int maNV, string loaiPhieu, string beginDay, string endDay)
        {
            InitializeComponent();

            //lblTenNV.Text = tenNV;
            //lblDate.Text = DateTime.Now.ToString("dddd, dd MMMM yyyy", Cons.CiVNI);

            this.taReport_HDNV.Connection.ConnectionString = UtilDB.ConnectionString;
            try
            {
                this.dataSetReport.EnforceConstraints = false;

                this.taReport_HDNV.Fill(this.dataSetReport.Report_HDNV, maNV, loaiPhieu, beginDay, endDay);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }

            var bds = UtilDB.BdsDSPM;

            //lblCN.Text = tenCN;
            //lblNhanVienLap.Text = UtilDB.CurrentFullName;
            //lblFromTo.Text = string.Format("TỪ {0} ĐẾN {1}", DateTime.Parse(beginDay, null).ToString("dd/MM/yyyy"), DateTime.Parse(endDay, null).ToString("dd/MM/yyyy"));
        }
Beispiel #7
0
        private void LoadTable()
        {
            // Đoạn này quan trọng. Đăng nhập bằng user nào => connectionString tương ứng
            this.taVT.Connection.ConnectionString               =
                this.taCTDDH.Connection.ConnectionString        =
                    this.taCTPN.Connection.ConnectionString     =
                        this.taCTPX.Connection.ConnectionString =
                            UtilDB.ConnectionString;

            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taVT.Fill(this.dataSet.Vattu);

                this.taCTDDH.Fill(this.dataSet.CTDDH);

                this.taCTPX.Fill(this.dataSet.CTPX);

                this.taCTPN.Fill(this.dataSet.CTPN);

                //this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #8
0
        private async void DeleteDepot()
        {
            _currentPosition = bdsDepot.Position;

            string ten    = ((DataRowView)bdsDepot[_currentPosition])["TENKHO"].ToString();
            var    result = XtraMessageBox.Show(string.Format(Cons.AskDeleteDepot, ten), Cons.CaptionWarning,
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                try
                {
                    // lưu lại data trước khi xóa
                    _userDo.Push(new ButtonAction(ButtonActionType.Delete, ((DataRowView)bdsDepot[_currentPosition]).Row.ItemArray));

                    //bdsDepot.RemoveCurrent();
                    //this.taDepot.Update(this.dataSet.Kho);
                    if (await UtilDB.DeleteInDB("Kho", "MAKHO", txtDepotId.EditValue))
                    {
                        this.dataSet.EnforceConstraints = false;
                        this.taDepot.Fill(this.dataSet.Kho);
                    }
                }
                catch (Exception ex)
                {
                    UtilDB.ShowError(ex);
                }
            }
        }
Beispiel #9
0
        private bool IsExistMaterial(string materialId)
        {
            string strLenh = string.Format(MyConfig.ExecSPTimVatTu, materialId);
            bool   exist   = true;

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                SqlCommand sqlcmd = new SqlCommand(strLenh, connection);
                sqlcmd.CommandType = CommandType.Text;
                try
                {
                    SqlDataReader myreader = sqlcmd.ExecuteReader();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == MyConfig.ErrorMsgNumNotExistObject)
                    {
                        exist = false;
                    }
                }
                catch (Exception ex)
                {
                    UtilDB.ShowError(ex);
                }
            }
            return(exist);
        }
Beispiel #10
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            string cnnStr = $"Data Source={MyConfig.RootServerName};" +
                            $"Initial Catalog={MyConfig.DatabaseName};" +
                            $"Integrated Security=True";

            try
            {
                UtilDB.BdsDSPM.DataSource = UtilDB.ExecSqlDataTable($"SELECT * FROM {MyConfig.ViewDSPMName}  ORDER BY {MyConfig.DisplayMemberDSPM}", cnnStr);
                if (UtilDB.BdsDSPM.DataSource == null)
                {
                    Close();
                    return;
                }

                cboChiNhanh.DataSource    = UtilDB.BdsDSPM;
                cboChiNhanh.DisplayMember = MyConfig.DisplayMemberDSPM;
                cboChiNhanh.ValueMember   = MyConfig.ValueMemberDSPM;

                cboChiNhanh.SelectedIndex = -1;
                cboChiNhanh.SelectedIndex = 0;
            }
            catch (SqlException ex)
            {
                UtilDB.ShowError(ex);
            }
            txtTK.Select();
        }
Beispiel #11
0
        private bool IsExistGoodsReceivedNote(string id)
        {
            bool exist = true;

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand sqlcmd = new SqlCommand(MyConfig.ExecSPTimPhieuNhap, connection))
                {
                    sqlcmd.CommandType = CommandType.StoredProcedure;
                    sqlcmd.Parameters.AddWithValue("@mapn", id);

                    try
                    {
                        sqlcmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == MyConfig.ErrorMsgNumNotExistObject)
                        {
                            exist = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                    }
                }
            }
            return(exist);
        }
Beispiel #12
0
        private bool RemoveLogin(string employeeId)
        {
            bool   isSuccess = false;
            string strLenh   = string.Format(MyConfig.ExecSPXoaLogin, employeeId);

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand sqlcmd = new SqlCommand(strLenh, connection))
                {
                    sqlcmd.CommandType = CommandType.Text;
                    try
                    {
                        sqlcmd.ExecuteNonQuery();
                        isSuccess = true;
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == MyConfig.ErrorMsgNumNotExistObject)
                        {
                            isSuccess = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                    }
                }
            }
            return(isSuccess);
        }
Beispiel #13
0
        private bool SaveDepot()
        {
            try
            {
                if (_buttonAction == ButtonActionType.Add &&
                    IsExistDepot(txtDepotId.EditValue.ToString()))
                {
                    XtraMessageBox.Show(Cons.ErrorDuplicateDeportId, Cons.CaptionWarning,
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtDepotId.Focus();
                    txtDepotId.SelectAll();
                    return(false);
                }

                bdsDepot.EndEdit();
                this.taDepot.Update(this.dataSet.Kho);
                gbDepot.Enabled = false;
                bdsDepot.ResetCurrentItem();
                DisableEditMode();
                if (_buttonAction == ButtonActionType.Add)
                {
                    // Lưu vô stack trạng thái nút nhấn và data bị thay đổi
                    _userDo.Push(new ButtonAction(_buttonAction, ((DataRowView)bdsDepot[bdsDepot.Position]).Row.ItemArray));
                }
                _buttonAction     = ButtonActionType.None;
                bdsDepot.Position = _currentPosition;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #14
0
        private bool IsExistDepot(string depotId)
        {
            bool   exist   = true;
            string strLenh = string.Format(MyConfig.ExecSPTimKho, depotId);

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand sqlcmd = new SqlCommand(strLenh, connection))
                {
                    sqlcmd.CommandType = CommandType.Text;
                    try
                    {
                        sqlcmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == MyConfig.ErrorMsgNumNotExistObject)
                        {
                            exist = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                    }
                }
            }
            return(exist);
        }
        private bool SaveDeliveryNote()
        {
            try
            {
                txtCustomerName.Text = txtCustomerName.Text.Trim();

                if (IsSaveGoodsDeliveryNote() == false)
                {
                    return(false);
                }

                SaveALlDataDetail();

                ((DataRowView)bdsPX.Current).Row.ItemArray = GetDataOrder();
                bdsPX.EndEdit();

                //UtilDB.UpdateWithTransaction(() =>
                //{
                //   this.taPX.Update(this.dataSet.PhieuXuat);
                //   this.taCTPX.Update(this.dataSet.CTPX);
                //}, taPX, taCTPX);

                using (var connection = new SqlConnection(UtilDB.ConnectionString))
                {
                    connection.Open();
                    using (var trans = connection.BeginTransaction())
                    {
                        taPX.Connection    = trans.Connection;
                        taCTPX.Connection  = trans.Connection;
                        taPX.Transaction   = trans;
                        taCTPX.Transaction = trans;

                        try
                        {
                            this.taPX.Update(this.dataSet.PhieuXuat);
                            this.taCTPX.Update(this.dataSet.CTPX);
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw ex;
                        }
                    }
                }
                taDSVTCH.Fill(dataSet.DSVTCONHANG);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                // xử lý tạm thời
                DisableEditMode();
                btnRefresh.PerformClick();
                return(false);
            }
            return(true);
        }
Beispiel #16
0
        private bool SaveOrder()
        {
            try
            {
                if (IsSaveOrder() == false)
                {
                    return(false);
                }

                SaveALlDataOrderDetailOnView();

                ((DataRowView)bdsDDH.Current).Row.ItemArray = GetDataOrder();
                bdsDDH.EndEdit();

                //UtilDB.UpdateWithTransaction(() =>
                //{
                //    this.taDDH.Update(this.dataSet.DatHang);
                //    this.taCTDDH.Update(this.dataSet.CTDDH);
                //}, taDDH, taCTDDH);
                using (var connection = new SqlConnection(UtilDB.ConnectionString))
                {
                    connection.Open();
                    using (var trans = connection.BeginTransaction())
                    {
                        taDDH.Connection    = trans.Connection;
                        taCTDDH.Connection  = trans.Connection;
                        taDDH.Transaction   = trans;
                        taCTDDH.Transaction = trans;

                        try
                        {
                            this.taDDH.Update(this.dataSet.DatHang);
                            this.taCTDDH.Update(this.dataSet.CTDDH);
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw ex;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                // xử lý tạm thời
                DisableEditMode();
                btnRefresh.PerformClick();
                return(false);
            }
            return(true);
        }
Beispiel #17
0
 private void cboChiNhanh_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboChiNhanh.SelectedValue == null)
     {
         return;
     }
     try
     {
         UtilDB.ServerName = cboChiNhanh.SelectedValue.ToString();
     }
     catch (Exception ex) { UtilDB.ShowError(ex); }
 }
        private void frmReportHDVN_Load(object sender, EventArgs e)
        {
            taDSNV.Connection.ConnectionString = UtilDB.ConnectionString;

            try
            {
                this.taDSNV.Fill(this.dataSet.DSNV);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #19
0
        private async void Undo()
        {
            ButtonAction action   = (ButtonAction)_userDo.Pop();
            int          position = -1;

            try
            {
                switch (action.ActionType)
                {
                case ButtonActionType.Add:
                    // xóa dữ liệu mới
                    //position = bdsNV.Find("MANV", action.SaveItems[0]);
                    //bdsNV.Remove((DataRowView)bdsNV[position]);
                    if (await UtilDB.DeleteInDB("NhanVien", "MANV", action.SaveItems[0]))
                    {
                        //this.dataSet.EnforceConstraints = false;
                        this.taNV.Fill(this.dataSet.NhanVien);
                        //this.dataSet.EnforceConstraints = true;
                    }
                    break;

                case ButtonActionType.Edit:
                    // sửa lại dữ liệu cũ
                    position = bdsNV.Find("MANV", action.SaveItems[0]);
                    ((DataRowView)bdsNV[position]).Row.ItemArray = action.SaveItems;
                    bdsNV.EndEdit();
                    //bdsNV.ResetCurrentItem();
                    break;

                case ButtonActionType.Delete:
                    // Thêm dữ liệu cũ vào
                    position = bdsNV.Count;
                    bdsNV.AddNew();
                    ((DataRowView)bdsNV[position]).Row.ItemArray = action.SaveItems;
                    bdsNV.EndEdit();
                    break;

                case ButtonActionType.None:
                default:
                    break;
                }
                this.taNV.Update(this.dataSet.NhanVien);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
        private void LoadTable()
        {
            this.taVTCONHANG.Connection.ConnectionString =
                UtilDB.ConnectionString;

            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taVTCONHANG.Fill(this.dataSet.DSVTCONHANG);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #21
0
        private bool CreateLogin(string loginName, string password, int employeeId, string roleName)
        {
            bool   result  = true;
            string strLenh = string.Format(MyConfig.ExecSPTaoTaiKhoan, loginName, password, employeeId, roleName);

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                SqlCommand sqlcmd = new SqlCommand(strLenh, connection);
                sqlcmd.CommandType = CommandType.Text;
                try
                {
                    sqlcmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    if (ex is SqlException)
                    {
                        var exAsSqlExeption = ex as SqlException;
                        if (exAsSqlExeption.Number == Cons.ErrorDuplicateLoginNameCode)
                        {
                            XtraMessageBox.Show(Cons.ErrorDuplicateLoginName, Cons.CaptionError,
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtLoginName.SelectAll();
                        }
                        else if (exAsSqlExeption.Number == Cons.ErrorDuplicateUserNameCode)
                        {
                            XtraMessageBox.Show(Cons.ErrorEmployeeHaveLogin, Cons.CaptionError,
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                            slkEmployee.Focus();
                        }
                        else
                        {
                            UtilDB.ShowError(ex);
                        }
                    }
                    else
                    {
                        UtilDB.ShowError(ex);
                    }
                    result = false;
                }
            }
            return(result);
        }
        private void btnCancelEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            dxErrorProvider.ClearErrors();
            try
            {
                bdsPX.CancelEdit();
                bdsPX.ResetCurrentItem();
                bdsPX.Position = _currentPosition;

                bdsCTPX.CancelEdit();

                DisableEditMode();
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Dùng username và mật khẩu khi connect thành công
        /// Exec sp_login để lấy Nhóm quyền, Tên, Mã NV
        /// </summary>
        /// <returns></returns>
        public static bool GetAndSaveUserInfoFromDB()
        {
            bool   flag    = true;
            string cmdText = string.Format(MyConfig.ExecSPThongTinDangNhap, UtilDB.CurrentLogin);

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                SqlCommand sqlcmd = new SqlCommand(cmdText, connection);
                sqlcmd.CommandType = CommandType.Text;

                using (SqlDataReader reader = sqlcmd.ExecuteReader())
                {
                    try
                    {
                        if (reader == null)
                        {
                            flag = false;
                        }

                        reader.Read();

                        UtilDB.UserName = reader.GetString(0); // Lay MANV
                        if (Convert.IsDBNull(UtilDB.UserName))
                        {
                            XtraMessageBox.Show(Cons.ErrorLogin, Cons.CaptionError, MessageBoxButtons.OK);
                            flag = false;
                        }
                        else
                        {
                            UtilDB.CurrentFullName = reader.GetString(1);
                            UtilDB.CurrentGroup    = reader.GetString(2);
                        }
                    }
                    catch (Exception ex)
                    {
                        UtilDB.ShowError(ex);
                        flag = false;
                    }
                }
            }
            return(flag);
        }
Beispiel #24
0
        private void LoadTable()
        {
            this.taDepot.Connection.ConnectionString  =
                this.taCN.Connection.ConnectionString =
                    UtilDB.ConnectionString;
            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taCN.Fill(this.dataSet.ChiNhanh);

                this.taDepot.Fill(this.dataSet.Kho);

                this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #25
0
        private async void btnDelete_ItemClick(object sender, ItemClickEventArgs e)
        {
            string constraint = CheckConstraint();

            if (constraint != null)
            {
                string text = string.Format(Cons.ErrorDeleteMaterial, constraint);
                XtraMessageBox.Show(text, Cons.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _currentPosition = bdsVT.Position;

            string ten    = ((DataRowView)bdsVT[_currentPosition])["TENVT"].ToString();
            var    result = XtraMessageBox.Show(string.Format(Cons.AskDeleteMaterials, ten), Cons.CaptionQuestion,
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                try
                {
                    // lưu lại data trước khi xóa
                    _userDo.Push(new ButtonAction(ButtonActionType.Delete, ((DataRowView)bdsVT[_currentPosition]).Row.ItemArray));

                    //bdsVT.RemoveCurrent();
                    //this.taVT.Update(this.dataSet.Vattu);
                    if (await UtilDB.DeleteInDB("Vattu", "MAVT", txtMaterialId.EditValue))
                    {
                        this.dataSet.EnforceConstraints = false;
                        this.taVT.Fill(this.dataSet.Vattu);
                    }
                }
                catch (Exception ex)
                {
                    UtilDB.ShowError(ex);
                }
            }

            cboDVT.DataSource = GetDanhSachDVT();
        }
Beispiel #26
0
        private void lkeMaDDH_EditValueChanged(object sender, EventArgs e)
        {
            var selectOrdeRow = lkeMaDDH.GetSelectedDataRow() as DataRowView;

            if (selectOrdeRow == null)
            {
                return;
            }

            lkeDepot.EditValue = selectOrdeRow.Row["MAKHO"].ToString();
            _maDDH             = lkeMaDDH.EditValue.ToString();

            try
            {
                int count = bdsCTPN.Count;
                for (int index = 0; index < count; index++)
                {
                    bdsCTPN.RemoveCurrent();
                    bdsCTPN.MovePrevious();
                }

                this.taDSVTDH.Fill(this.dataSet.DSVTDH, _maDDH);

                count = bdsDSVTDH.Count;
                for (int index = 0; index < count; index++)
                {
                    bdsCTPN.AddNew();
                    ((DataRowView)bdsCTPN.Current).Row["MAVT"]    = ((DataRowView)bdsDSVTDH.Current).Row["MAVT"];
                    ((DataRowView)bdsCTPN.Current).Row["SOLUONG"] = ((DataRowView)bdsDSVTDH.Current).Row["SOLUONG"];
                    ((DataRowView)bdsCTPN.Current).Row["DONGIA"]  = ((DataRowView)bdsDSVTDH.Current).Row["DONGIA"];
                    bdsDSVTDH.MoveNext();
                }
                bdsCTPN.EndEdit();
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #27
0
        private void btnCancelEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            dxErrorProvider.ClearErrors();

            try
            {
                gbDepot.Enabled = false;
                bdsDepot.CancelEdit();
                bdsDepot.ResetCurrentItem();
                bdsDepot.Position = _currentPosition;
                if (_buttonAction == ButtonActionType.Edit)
                {
                    _userDo.Pop();
                }
                _buttonAction = ButtonActionType.None;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
            DisableEditMode();
        }
Beispiel #28
0
        private void LoadTable()
        {
            this.taDSKHO.Connection.ConnectionString            =
                this.taDSNCC.Connection.ConnectionString        =
                    this.taDSNV.Connection.ConnectionString     =
                        this.taDSVT.Connection.ConnectionString =
                            UtilDB.ConnectionString;

            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taDSNCC.Fill(this.dataSet.DSNCC);
                this.taDSNV.Fill(this.dataSet.DSNV);
                this.taDSKHO.Fill(this.dataSet.DSKHO);
                this.taDSVT.Fill(this.dataSet.DSVT);
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }
Beispiel #29
0
        private bool SaveEmployee()
        {
            if (_buttonAction == ButtonActionType.Add)
            {
                txtEmpId.EditValue = UtilDB.GenerateEmployeeId();
            }

            TrimAll();

            if (!IsValidEmptyValue())
            {
                (dxErrorProvider.GetControlsWithError()[0] as BaseEdit).SelectAll();
                return(false);
            }
            if (!IsValidCustom())
            {
                (dxErrorProvider.GetControlsWithError()[0] as BaseEdit).SelectAll();
                return(false);
            }

            try
            {
                EndEdit();
                if (_buttonAction == ButtonActionType.Add)
                {
                    // Lưu vô stack trạng thái nút nhấn và data bị mới
                    _userDo.Push(new ButtonAction(_buttonAction, ((DataRowView)bdsNV[bdsNV.Position]).Row.ItemArray));
                }
                _buttonAction  = ButtonActionType.None;
                bdsNV.Position = _currentPosition;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                return(false);
            }
            return(true);
        }
Beispiel #30
0
        private void LoadTable()
        {
            // Đoạn này quan trọng. Đăng nhập bằng user nào => connectionString tương ứng
            this.taPN.Connection.ConnectionString =
                this.taDSDDHChuaCoPhieuNhap.Connection.ConnectionString           =
                    this.taCTPN.Connection.ConnectionString                       =
                        this.taDSKHO.Connection.ConnectionString                  =
                            this.taDDH.Connection.ConnectionString                =
                                this.taDSNV.Connection.ConnectionString           =
                                    this.taDSVT.Connection.ConnectionString       =
                                        this.taDSVTDH.Connection.ConnectionString =
                                            UtilDB.ConnectionString;
            try
            {
                this.dataSet.EnforceConstraints = false;

                this.taPN.Fill(this.dataSet.PhieuNhap);

                this.taDSDDHChuaCoPhieuNhap.Fill(this.dataSet.sp_dsddhchuacophieunhap);

                this.taCTPN.Fill(this.dataSet.CTPN);

                this.taDSKHO.Fill(this.dataSet.DSKHO);

                this.taDDH.Fill(this.dataSet.DatHang);

                this.taDSNV.Fill(this.dataSet.DSNV);

                this.taDSVT.Fill(this.dataSet.DSVT);

                //this.dataSet.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
        }