Esempio n. 1
0
        //when user click on first column then show all of clerk information
        private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && DataGridView1.Rows.Count >0)
            {
                DataTable dt = _DA.Do_Table(_DA.Do_Sql_Adapter("SELECT * FROM clerk WHERE code=" + DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString().Trim()));
                foreach (Control item in elRichPanel7.Controls)
                {
                    if (item is ELEntryBox)
                    {
                        if ((item as ELEntryBox).Tag.ToString() != "")
                        {
                            (item as ELEntryBox).Value = dt.Rows[0][(item as ELEntryBox).Tag.ToString()].ToString().Trim();
                        }
                    }
                }
                elEntryBox21.Value = elEntryBox21.Value.ToString().Remove(elEntryBox21.Value.ToString().Length - 3, 3);
                elEntryBox22.Value = elEntryBox22.Value.ToString().Remove(elEntryBox22.Value.ToString().Length - 3, 3);
                BLL.picture pic = new BLL.picture();
                pictureBox1.Image = pic.GettingPicture(elEntryBox1.Value.ToString());
                if (pictureBox1.Image == null) { pictureBox1.Image = Almas.Properties.Resources.user; }

                elRadioButton2.Checked = bool.Parse(dt.Rows[0]["sex"].ToString()) == false ? true : false;
                elRadioButton3.Checked = bool.Parse(dt.Rows[0]["sex"].ToString()) == true ? true : false;
                elCheckBox1.Checked = bool.Parse(dt.Rows[0]["insurance"].ToString());
                elEntryBox8.Value = (dt.Rows[0]["relation"].ToString() == "True") ? "متاهل" : "مجرد";
                elEntryBox9.Value = (dt.Rows[0]["military"].ToString() == "True") ? "دارای کارت پایان خدمت" : "بدون کارت پایان خدمت";
                elEntryBox7.Value = DateTime.Parse(dt.Rows[0]["birth_date"].ToString()).ToShortDateString();
                elEntryBox10.Value = _DA.Do_Table(_DA.Do_Sql_Adapter("Select name from education where ID =" + dt.Rows[0]["education"].ToString().Trim())).Rows[0]["name"].ToString();
                elEntryBox11.Value = _DA.Do_Table(_DA.Do_Sql_Adapter("Select name from religion_pri where ID =" + dt.Rows[0]["religion_pri"].ToString().Trim())).Rows[0]["name"].ToString();
                elEntryBox12.Value = _DA.Do_Table(_DA.Do_Sql_Adapter("Select name from religion_sec where ID =" + dt.Rows[0]["religion_sec"].ToString().Trim())).Rows[0]["name"].ToString();
                elEntryBox13.Value = _DA.Do_Table(_DA.Do_Sql_Adapter("Select name from united where ID =" + dt.Rows[0]["united"].ToString().Trim())).Rows[0]["name"].ToString();
                elEntryBox14.Value = _DA.Do_Table(_DA.Do_Sql_Adapter("Select name from city where ID =" + dt.Rows[0]["city"].ToString().Trim())).Rows[0]["name"].ToString();
                string illnessFromDB = dt.Rows[0]["illness"].ToString().Remove(0,1);
                int[] illness_num = new int[(illnessFromDB.Length / 3)];

                for (int i = 0; illnessFromDB.Length > 1; i++)
                {
                    illness_num[i] = int.Parse(illnessFromDB.Substring(0, illnessFromDB.IndexOf(",,")).ToString()) ;
                    illnessFromDB = illnessFromDB.Remove(0, illnessFromDB.IndexOf(",,") + 2);
                }

                elEntryBox23.Items.Clear();
                foreach (DataRow item in _PublicClass.Illness().Rows)
                {
                    ELListBoxItem ExItem = new ELListBoxItem();
                    ExItem.Key = item[0];
                    ExItem.Value = item[1];
                    foreach (int item_key in illness_num)
                    {
                        if (item_key == int.Parse(item[0].ToString()))
                        {
                            ExItem.CheckState = CheckState.Checked;
                        }
                    }
                    elEntryBox23.Items.Add(ExItem);
                }

                Modal1.Show(this, elRichPanel7);
            }
        }
Esempio n. 2
0
        //store final clerk data in db
        private void elButton1_Click(object sender, EventArgs e)
        {
            if (Check_Empty_Entrybox())
            {
                if (extramessage_frm.Show("آیا مایل به ثبت اطلاعات این منشی هستید ؟ ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                {
                    byte sex = (elRadioButton1.Checked == true) ? (byte)0 : (byte)1;
                    byte insurance = (elCheckBox1.Checked == true) ? (byte)1 : (byte)0;
                    //search checked item in elentrybox23 and save item.key in new string
                    string disease = _PublicClass.Fetch_Checked_Item(elEntryBox23.CheckedItems);

                    BLL.cleark crk = new BLL.cleark();
                    if (crk.Insert((string)elEntryBox1.Value, (string)elEntryBox2.Value, (string)elEntryBox3.Value,
                        (string)elEntryBox4.Value, (string)elEntryBox5.Value, (string)elEntryBox6.Value, sex,
                        (string)elEntryBox7.Value, byte.Parse(elEntryBox8.SelectedKey.ToString()), byte.Parse(elEntryBox9.SelectedKey.ToString()),
                        int.Parse(elEntryBox10.SelectedKey.ToString()), int.Parse(elEntryBox11.SelectedKey.ToString()), int.Parse(elEntryBox12.SelectedKey.ToString()),
                        int.Parse(elEntryBox13.SelectedKey.ToString()), int.Parse(elEntryBox14.SelectedKey.ToString()), (string)elEntryBox15.Value,
                        (string)elEntryBox16.Value, (string)elEntryBox17.Value, (string)elEntryBox18.Value,
                        int.Parse(elEntryBox19.Value.ToString()), (string)elEntryBox20.Value, insurance, (string)elEntryBox21.Value, (string)elEntryBox22.Value, disease))
                    {
                        //save user image into db [ image table ]
                        BLL.picture _Pic = new BLL.picture();
                        _Pic.InsertPicture((string)elEntryBox1.Value, pictureBox1.Image);
                        //empty all of elentrybox and combobox and picturebox
                        elButton2_Click(null, null);
                    }
                }
            }
        }