Exemplo n.º 1
0
        private void FrmSalhaCed_Load(object sender, EventArgs e)
        {
            FillcmbMajmoehaList();
            if (this.Text != "ایجاد رکورد جدید")
            {
                cmbMajmoehaList.EditValue = Convert.ToInt32(Fm.gridView1.GetFocusedRowCellValue("MsMajmoeId").ToString());
                cmbVahedhaList.EditValue  = Convert.ToInt32(Fm.gridView1.GetFocusedRowCellValue("MsVahedId").ToString());
                cmbShobeList.EditValue    = Convert.ToInt32(Fm.gridView1.GetFocusedRowCellValue("MsShobeId").ToString());
                txtId.Text              = Fm.gridView1.GetFocusedRowCellValue("MsSalMaliId").ToString();
                txtCode.Text            = Fm.gridView1.GetFocusedRowCellValue("SalMaliCode").ToString().Substring(6);
                txtSalMali.Text         = Fm.gridView1.GetFocusedRowCellValue("SalMali").ToString();
                txtStartSal.EditValue   = Fm.gridView1.GetFocusedRowCellValue("StartSalMali").ToString().Substring(0, 10);
                txtEndSal.EditValue     = Fm.gridView1.GetFocusedRowCellValue("EndSalMali").ToString().Substring(0, 10);
                chkIsActive.Checked     = Convert.ToBoolean(Fm.gridView1.GetFocusedRowCellValue("SalMaliIsActive"));
                chkSalIsDefault.Checked = Convert.ToBoolean(Fm.gridView1.GetFocusedRowCellValue("SalIsDefault"));
                chkSalIsClose.Checked   = Convert.ToBoolean(Fm.gridView1.GetFocusedRowCellValue("SalIsClose"));
                txtMaliat.Text          = Fm.gridView1.GetFocusedRowCellValue("Maliat").ToString();
                txtAvarez.Text          = Fm.gridView1.GetFocusedRowCellValue("Avarez").ToString();

                CodeBeforeEdit = txtCode.Text;
                NameBeforeEdit = txtSalMali.Text;
                RowId          = Convert.ToInt32(txtId.Text);

                using (var db = new MyContext())
                {
                    try
                    {
                        var q = db.RmsSalMalihaBmsUserhas.Where(s => s.MsSalMaliId == RowId).Select(s => s.MsUserId).ToList();

                        string CheckedItems = string.Empty;
                        foreach (var item in q)
                        {
                            CheckedItems += item.ToString() + ",";
                        }

                        chkcmbPermissiveUsers.SetEditValue(CheckedItems);
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show("عملیات با خطا مواجه شد" + "\n" + ex.Message,
                                            "پیغام", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                HelpClass1.SetCurrentYear(txtSalMali);
                txtStartSal.Text = txtSalMali.Text + "/" + "01/01";
                txtEndSal.Text   = txtSalMali.Text + "/" + "12/29";
            }
        }