Esempio n. 1
0
        private void EnableEditControls(bool enabled)
        {
            if (this.Phai.ToLower() == GxConstants.NU.ToLower())
            {
                txtNguoiChong.EditControl.Enabled = enabled;
            }
            else
            {
                txtNguoiVo.EditControl.Enabled = enabled;
            }
            txtNguoiVo.ReadOnly    = true;
            txtNguoiChong.ReadOnly = true;

            if (!enabled)
            {
                setReadOnlyControls(true);
                gxAddEdit1.SelectButton.Enabled = false;
                gxAddEdit1.AddButton.Enabled    = true;
                DataTable tb = gxHonPhoiList1.DataSource as DataTable;
                if (tb != null && tb.Rows.Count > 0)
                {
                    gxAddEdit1.EditButton.Enabled   = true;
                    gxAddEdit1.DeleteButton.Enabled = true;
                }
                operation = GxOperation.NONE;
                gxAddEdit1.AddButton.Text  = "&Thêm";
                gxAddEdit1.EditButton.Text = "&Sửa";
                return;
            }
            //if (operation == GxOperation.ADD) txtMaHonPhoi.ReadOnly = false;
            setReadOnlyControls(false);
            gxAddEdit1.SelectButton.Enabled = true;
            gxAddEdit1.AddButton.Enabled    = false;
            gxAddEdit1.EditButton.Enabled   = false;
            gxAddEdit1.DeleteButton.Enabled = false;
            if (operation == GxOperation.ADD)
            {
                gxAddEdit1.AddButton.Enabled = true;
                gxAddEdit1.AddButton.Text    = "&Thôi";
            }
            else if (operation == GxOperation.EDIT)
            {
                gxAddEdit1.EditButton.Enabled = true;
                gxAddEdit1.EditButton.Text    = "&Thôi";
            }
        }
Esempio n. 2
0
        public DataTable GetHonPhoi(int maNguoiVo, int maNguoiChong)
        {
            if (maNguoiChong < 1 || maNguoiVo < 1)
            {
                return(null);
            }
            nguoiVo    = maNguoiVo;
            nguoiChong = maNguoiChong;
            //DataTable tblCheck = Memory.GetData(SqlConstants.SELECT_HONPHOI_THEO_MAGIAODAN + " AND GiaoDanHonPhoi_1.MaGiaoDan = ?", new object[] { maNguoiVo, nguoiChong });
            DataTable tblCheck = GetHonPhoiTheoVoChong(maNguoiVo, maNguoiChong);

            if (!Memory.ShowError() && tblCheck != null && tblCheck.Rows.Count > 0)
            {
                int maHP = (int)tblCheck.Rows[0][HonPhoiConst.MaHonPhoi];
                AssignControlData(tblCheck.Rows[0]);
                operation = GxOperation.EDIT;
                return(tblCheck);
            }
            ClearControlData();
            operation = GxOperation.ADD;
            return(null);
        }
Esempio n. 3
0
        private void EditLinhMucRow(GxOperation op)
        {
            if (op == GxOperation.EDIT && (gxLinhMucList1.CurrentRow == null || (gxLinhMucList1.CurrentRow.DataRow as DataRowView) == null))
            {
                return;
            }
            frmLinhMuc frm = new frmLinhMuc();

            frm.Operation = op;
            DataRow row = null;

            if (op == GxOperation.EDIT)
            {
                row    = (gxLinhMucList1.CurrentRow.DataRow as DataRowView).Row;
                frm.Id = (int)row[LinhMucConst.MaLinhMuc];
                frm.AssignControlData();
                showForm(row, frm);
            }
            else
            {
                DataTable tbl = gxLinhMucList1.DataSource as DataTable;
                if (tbl == null)
                {
                    tbl = Memory.GetData(SqlConstants.SELECT_LINHMUC_LIST);
                    if (Memory.ShowError())
                    {
                        return;
                    }
                    gxLinhMucList1.DataSource = tbl;
                }
                row = tbl.NewRow();
                DialogResult rs = showForm(row, frm);
                if (rs == DialogResult.OK)
                {
                    tbl.Rows.Add(row);
                }
            }
        }
Esempio n. 4
0
        public bool UpdateHonPhoi()
        {
            try
            {
                if (checkInput())
                {
                    //check ton tai roi
                    DataTable tblHonPhoi = GxHonPhoi.HonPhoiExists(NguoiChong, NguoiVo);
                    if (tblHonPhoi != null && tblHonPhoi.Rows.Count > 0)
                    {
                        operation = GxOperation.EDIT;
                        maHonPhoi = (int)tblHonPhoi.Rows[0][HonPhoiConst.MaHonPhoi];
                    }
                    else
                    {
                        tblHonPhoi = Memory.GetData(SqlConstants.SELECT_HONPHOI_THEO_ID, new object[] { maHonPhoi });
                        if (Memory.ShowError() || tblHonPhoi == null)
                        {
                            return(false);
                        }
                        if (tblHonPhoi.Rows.Count == 0)
                        {
                            maHonPhoi = Memory.Instance.GetNextId(HonPhoiConst.TableName, HonPhoiConst.MaHonPhoi, false);
                            operation = GxOperation.ADD;
                        }
                    }
                    tblHonPhoi.TableName = HonPhoiConst.TableName;
                    DataRow dataReturn = null;
                    if (operation == GxOperation.ADD)
                    {
                        dataReturn = tblHonPhoi.NewRow();
                        AssignDataSource(dataReturn);
                        tblHonPhoi.Rows.Add(dataReturn);
                    }
                    else if (operation == GxOperation.EDIT)
                    {
                        if (tblHonPhoi.Rows.Count > 0)
                        {
                            dataReturn = tblHonPhoi.Rows[0];
                            AssignDataSource(dataReturn);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                    DataSet ds = new DataSet();
                    ds.Tables.Add(tblHonPhoi);
                    //Update UpdateDate field
                    foreach (DataRow rowTmp in tblHonPhoi.Rows)
                    {
                        rowTmp[GiaoDanConst.UpdateDate] = Memory.Instance.GetServerDateTime();
                    }
                    //delete GiaoDanHonPhoi
                    if (operation == GxOperation.EDIT)
                    {
                        string deleteSql = "DELETE FROM GiaoDanHonPhoi WHERE MaHonPhoi=?";
                        Memory.ExecuteSqlCommand(deleteSql, new object[] { maHonPhoi });
                        if (Memory.ShowError())
                        {
                            return(false);
                        }
                    }
                    DataTable tblGiaoDanHonPhoi = Memory.GetTableStruct(GiaoDanHonPhoiConst.TableName);
                    //them nguoi nam
                    DataRow newRow = tblGiaoDanHonPhoi.NewRow();
                    newRow[GiaoDanHonPhoiConst.MaHonPhoi] = maHonPhoi;
                    newRow[GiaoDanHonPhoiConst.MaGiaoDan] = NguoiVo;
                    newRow[GiaoDanHonPhoiConst.SoThuTu]   = GxHonPhoi.GetNextSoThuTu(NguoiVo);
                    tblGiaoDanHonPhoi.Rows.Add(newRow);

                    //them nguoi nu
                    newRow = tblGiaoDanHonPhoi.NewRow();
                    newRow[GiaoDanHonPhoiConst.MaHonPhoi] = maHonPhoi;
                    newRow[GiaoDanHonPhoiConst.MaGiaoDan] = NguoiChong;
                    newRow[GiaoDanHonPhoiConst.SoThuTu]   = GxHonPhoi.GetNextSoThuTu(NguoiChong);
                    tblGiaoDanHonPhoi.Rows.Add(newRow);

                    //add to data set
                    ds.Tables.Add(tblGiaoDanHonPhoi);

                    Memory.UpdateDataSet(ds);
                    ds.Tables.Remove(tblHonPhoi);
                    if (Memory.ShowError())
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi Exception (GxHonPhoiGiaDinh, UpdateHonPhoi)", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(false);
        }