コード例 #1
0
        private void cboThuoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string khoCapCuuGUID = cboKhoCapCuu.SelectedValue.ToString();
            Result result        = NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu(khoCapCuuGUID);

            if (!result.IsOK)
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"));
                return;
            }

            if (result.QueryResult != null)
            {
                dtpkNgayHetHan.Value = Convert.ToDateTime(result.QueryResult);
            }

            result = NhapKhoCapCuuBus.GetKhoCapCuuTonKho(khoCapCuuGUID);
            if (!result.IsOK)
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"));
                return;
            }

            if (result.QueryResult != null)
            {
                numSoLuongTon.Value = Convert.ToInt32(result.QueryResult);
            }
        }
コード例 #2
0
        private void cmbox_SelectedValueChanged(object sender, EventArgs e)
        {
            if (!_flag)
            {
                return;
            }

            if (dgChiTiet.CurrentCell.ColumnIndex == 1)
            {
                _flag = false;
                DataGridViewComboBoxEditingControl cbo = (DataGridViewComboBoxEditingControl)sender;
                if (cbo.SelectedValue == null || cbo.SelectedValue.ToString() == "System.Data.DataRowView")
                {
                    return;
                }
                string khoCapCuuGUID = cbo.SelectedValue.ToString();

                Result result = NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu(khoCapCuuGUID);
                if (result.IsOK)
                {
                    if (result.QueryResult != null)
                    {
                        DateTime ngayHetHan = Convert.ToDateTime(result.QueryResult);
                        dgChiTiet.Rows[dgChiTiet.CurrentRow.Index].Cells[3].Value = ngayHetHan;
                    }
                    else
                    {
                        dgChiTiet.Rows[dgChiTiet.CurrentRow.Index].Cells[3].Value = DBNull.Value;
                    }
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"));
                }

                result = NhapKhoCapCuuBus.GetKhoCapCuuTonKho(khoCapCuuGUID);
                if (result.IsOK)
                {
                    if (result.QueryResult != null)
                    {
                        int soLuongTon = Convert.ToInt32(result.QueryResult);
                        dgChiTiet.Rows[dgChiTiet.CurrentRow.Index].Cells[4].Value = soLuongTon;
                    }
                    else
                    {
                        dgChiTiet.Rows[dgChiTiet.CurrentRow.Index].Cells[4].Value = DBNull.Value;
                    }
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"));
                }
                _flag = true;
            }
        }
コード例 #3
0
        private void UpdateNgayHetHanVaSoLuongTon()
        {
            foreach (DataGridViewRow row in dgChiTiet.Rows)
            {
                if (row.Cells["KhoCapCuuGUID"].Value == null || row.Cells["KhoCapCuuGUID"].Value == DBNull.Value ||
                    row.Cells["KhoCapCuuGUID"].Value.ToString() == Guid.Empty.ToString())
                {
                    continue;
                }

                string khoCapCuuGUID = row.Cells["KhoCapCuuGUID"].Value.ToString();
                Result result        = NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu(khoCapCuuGUID);
                if (result.IsOK)
                {
                    if (result.QueryResult != null)
                    {
                        DateTime ngayHetHan = Convert.ToDateTime(result.QueryResult);
                        row.Cells[3].Value = ngayHetHan;
                    }
                    else
                    {
                        row.Cells[3].Value = DBNull.Value;
                    }
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetNgayHetHanCuaKhoCapCuu"));
                }

                result = NhapKhoCapCuuBus.GetKhoCapCuuTonKho(khoCapCuuGUID);
                if (result.IsOK)
                {
                    if (result.QueryResult != null)
                    {
                        int soLuongTon = Convert.ToInt32(result.QueryResult);
                        row.Cells[4].Value = soLuongTon;
                    }
                    else
                    {
                        row.Cells[4].Value = DBNull.Value;
                    }
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("NhapKhoCapCuuBus.GetKhoCapCuuTonKho"));
                }
            }
        }