コード例 #1
0
        /// <summary>
        /// 3. Loads the info client in to the dataGridView
        /// </summary>
        private void DisplayClients()
        {
            // new Controller cleans the object everytime it is called
            // new Controllercleans the view with every click
            clsInfo Controller = new clsInfo();

            gvClient.DataSource = Controller.LoadClients();
        }
コード例 #2
0
        /// <summary>
        /// 1. Loads Employees in the combo box employees
        /// </summary>
        private void ListEmployees()
        {
            // new Controller cleans the object everytime it is called
            // new Controllercleans the view with every click
            clsInfo Controller = new clsInfo();

            cmbEmployees.DataSource    = Controller.EmployeeList();
            cmbEmployees.DisplayMember = "Employee";
            cmbEmployees.ValueMember   = "idEmployee";
        }
コード例 #3
0
        /// <summary>
        /// 2. Loads Agencies in the combo box agencies
        /// </summary>
        private void ListAgencies()
        {
            // new Controller cleans the object everytime it is called
            // new Controllercleans the view with every click
            clsInfo Controller = new clsInfo();

            cmbAgencies.DataSource    = Controller.AgenciesList();
            cmbAgencies.DisplayMember = "Agency";
            cmbAgencies.ValueMember   = "idagencies";
        }
コード例 #4
0
    private void XoaTin()
    {
        clsInfo info = new clsInfo();

        foreach (RepeaterItem item in rptTieuDe.Items)
        {
            Label lblID = (Label)item.FindControl("lblID");
            info.MaGioiThieu = int.Parse(lblID.Text);
            info.Gioithieu_xoa();
        }
    }
コード例 #5
0
        private void LoadData(string _Code)
        {
            _lname = "";
            try
            {
                lst.Clear();
                using (var db = new Gobibase())
                {
                    Cursor.Current = Cursors.WaitCursor;

                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    SqlCommand    cmd  = new SqlCommand("SELECT [id],[code],[name],[nameen],[l_name],[angilal],[sortid],[other1],[other2] FROM [t_info] where l_name='" + _Code + "'", conn);
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            clsInfo f = new clsInfo();
                            f.ID      = dr.IsDBNull(0) ? 0 : Core.ToInt(dr.GetInt32(0));
                            f.Code    = dr.IsDBNull(1) ? "" : Core.ToStr(dr.GetString(1));
                            f.Name    = dr.IsDBNull(2) ? "" : Core.ToStr(dr.GetString(2));
                            f.Nameen  = dr.IsDBNull(3) ? "" : Core.ToStr(dr.GetString(3));
                            f.L_name  = dr.IsDBNull(4) ? "" : Core.ToStr(dr.GetString(4));
                            f.Angilal = dr.IsDBNull(5) ? "" : Core.ToStr(dr.GetString(5));
                            f.Sortid  = dr.IsDBNull(6) ? 0 : Core.ToInt(dr.GetInt32(6));
                            f.Other1  = dr.IsDBNull(7) ? "" : Core.ToStr(dr.GetString(7));
                            f.Other2  = dr.IsDBNull(8) ? "" : Core.ToStr(dr.GetString(8));
                            lst.Add(f);
                        }
                    }

                    conn.Close();
                    dr.Close();

                    _lname = Core.ToStr(comboBoxEdit1.Text);

                    Cursor.Current = Cursors.Default;
                }

                gridControl1.DataSource = lst.ToList();
            }

            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Шинэчлэх үед алдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
 public JsonResult SeletedDelete(clsInfo _clsInfo)
 {
     try
     {
         var item = tblcon.GetAll(x => _clsInfo.Ids.Contains(x.Id)).ToList();
         tblcon.BulkDelete(item);
         tblcon.Save();
         var result = new { Info = "Success", Formatting.None };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(null);
 }
コード例 #7
0
 /// <summary>
 /// 8. Loads the grid view with combo box employee selector
 /// </summary>
 private void cmbEmployees_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         clsInfo Controller = new clsInfo();
         stringcmboxemployee = cmbEmployees.Text;
         stringdbaseemployee = Controller.ReaderEmployee(stringcmboxemployee);
         gvClient.DataSource = Controller.selectqclientByemployeeNumber(stringdbaseemployee);
         CleanTextboxes();
         btnRefresh.Text = "Refresh >>>";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error  : " + " " + ex.Message);
     }
 }
コード例 #8
0
 /// <summary>
 /// 7. Loads the grid view with combo box agency selector
 /// </summary>
 private void cmbAgencies_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         clsInfo Controller = new clsInfo();
         // static variables agency
         stringcmboxagency   = cmbAgencies.Text;
         stringdbaseagency   = Controller.ReaderAgency(stringcmboxagency);
         gvClient.DataSource = Controller.selectqclientByAgency(stringdbaseagency);
         CleanTextboxes();
         btnRefresh.Text = "Refresh >>>";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error  : " + " " + ex.Message);
     }
 }
コード例 #9
0
ファイル: frmMass.cs プロジェクト: ganzoriggnz/CreateItemcode
        private void LoadInfo()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                using (var db = new Gobibase())
                {
                    lst_info.Clear();
                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    SqlCommand    cmd  = new SqlCommand("SELECT [id],[code],[name],[nameen],[l_name],[angilal],[sortid],[other1],[other2] FROM [t_info]" + StrWhere(), conn);
                    cmd.CommandType = CommandType.Text;
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            clsInfo g = new clsInfo();
                            g.ID      = dr.IsDBNull(0) ? 0 : Core.ToInt(dr.GetInt32(0));
                            g.Code    = dr.IsDBNull(1) ? "" : Core.ToStr(dr.GetString(1));
                            g.Name    = dr.IsDBNull(2) ? "" : Core.ToStr(dr.GetString(2));
                            g.Nameen  = dr.IsDBNull(3) ? "" : Core.ToStr(dr.GetString(3));
                            g.L_name  = dr.IsDBNull(4) ? "" : Core.ToStr(dr.GetString(4));
                            g.Angilal = dr.IsDBNull(5) ? "" : Core.ToStr(dr.GetString(5));
                            g.Sortid  = dr.IsDBNull(6) ? 0 : Core.ToInt(dr.GetInt32(6));
                            g.Other1  = dr.IsDBNull(7) ? "" : Core.ToStr(dr.GetString(7));
                            g.Other2  = dr.IsDBNull(8) ? "" : Core.ToStr(dr.GetString(8));
                            lst_info.Add(g);
                        }
                    }

                    conn.Close();
                    dr.Close();

                    Cursor.Current = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Aлдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #10
0
        private void LoadRefSection()
        {
            try
            {
                using (var db = new Gobibase())
                {
                    Cursor.Current = Cursors.WaitCursor;

                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    SqlCommand    cmd  = new SqlCommand("select l_name from t_info group by l_name order by l_name", conn);
                    cmd.CommandType = CommandType.Text;
                    conn.Open();
                    SqlDataReader  dr     = cmd.ExecuteReader();
                    List <clsInfo> temp_l = new List <clsInfo>();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            clsInfo f = new clsInfo();
                            f.Name = dr.IsDBNull(0) ? "" : Core.ToStr(dr.GetString(0));
                            temp_l.Add(f);
                        }
                    }

                    conn.Close();
                    dr.Close();

                    comboBoxEdit1.Properties.ValueMember   = "Name";
                    comboBoxEdit1.Properties.DisplayMember = "Name";
                    comboBoxEdit1.Properties.DataSource    = temp_l.ToList();


                    Cursor.Current = Cursors.Default;
                }
            }

            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Шинэчлэх үед алдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #11
0
        private void repoEdit_Click(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0)
            {
                return;
            }
            clsInfo curr = (clsInfo)gridView1.GetFocusedRow();

            if (curr.ID != 0)
            {
                frmLevelDetail fu = new frmLevelDetail(curr);
                fu.ShowDialog();

                if (fu.Tag != null)
                {
                    LoadRefSection();
                    LoadData(Core.ToStr(comboBoxEdit1.EditValue));
                }
            }
        }
コード例 #12
0
ファイル: frmMass.cs プロジェクト: ganzoriggnz/CreateItemcode
        private void luplbl6_EditValueChanged(object sender, EventArgs e)
        {
            luplbl7.EditValue       = null;
            txtMainColor2.EditValue = null;

            clsInfo rw = (clsInfo)luplbl6.GetSelectedDataRow();

            if (rw != null)
            {
                if (rw.CodeName.ToLower().Contains("принт"))
                {
                    layoutControlItem10.Enabled = false;
                    txtMainColor2.ReadOnly      = false;
                }
                else
                {
                    layoutControlItem10.Enabled = true;
                    txtMainColor2.ReadOnly      = true;
                }
            }
        }
コード例 #13
0
 /// <summary>
 /// 5. Save or update the info client in the data base
 /// </summary>
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         // 1. Get client info from text boxes
         string idclient     = txtidclient.Text.Trim();
         string clientNumber = txtclientNumber.Text.Trim();
         string name         = txtname.Text.Trim();
         string lastName     = txtlastName.Text.Trim();
         string email        = txtemail.Text.Trim();
         string img          = txtimg.Text.Trim();
         string address      = txtaddress.Text.Trim();
         string cardNumber   = txtcardNumber.Text.Trim();
         string nip          = txtnip.Text.Trim();
         string idagencies   = cmbAgencies.SelectedValue.ToString();
         string idemployee   = cmbEmployees.SelectedValue.ToString();
         string sexe         = txtsexe.Text.Trim();
         // 2. Obj Controller
         clsInfo Controller = new clsInfo();
         // 3. Save or update client info
         Controller.SaveClient(idclient, clientNumber, name, lastName, email, img, address, cardNumber, nip, idagencies, idemployee, sexe);
         if (idclient != "0")
         {
             MessageBox.Show("Msg : " + " " + " client has been updated");
         }
         else
         {
             MessageBox.Show("Msg : " + " " + " client has been saved");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error  : " + " " + ex.Message);
     }
     // Refresh the dataGridView
     DisplayClients();
     // Cleans the text boxws in the form
     CleanTextboxes();
 }
コード例 #14
0
        /// <summary>
        /// 6. Delete the info client in to the data base
        /// </summary>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // 1. Get client info from text boxes
            string idclient = txtidclient.Text.Trim();

            try
            {
                // 2. Obj Controller
                clsInfo Controller = new clsInfo();
                // 3. Deleteclient info
                Controller.DeleteClient(idclient);
                // 4. Loads the info client in to the dataGridView
                DisplayClients();
                // 5. cleaan the text boxes
                CleanTextboxes();
                // 6. Message
                MessageBox.Show("Msg : " + " " + " client has been deleted");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error  : " + " " + ex.Message);
            }
        }
コード例 #15
0
        private void LastRowData()
        {
            try
            {
                using (var db = new Gobibase())
                {
                    Cursor.Current = Cursors.WaitCursor;

                    lastRowData = new clsInfo();
                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    SqlCommand    cmd  = new SqlCommand("select top 1 angilal,sortid from t_info where l_name = @p1 order by sortid desc", conn);
                    cmd.Parameters.Add("@p1", SqlDbType.NVarChar, 50).Value = frmCreateZagvar._lname;
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            lastRowData.Angilal = dr.IsDBNull(0) ? "" : Core.ToStr(dr.GetString(0));
                            lastRowData.Sortid  = dr.IsDBNull(1) ? 0 : Core.ToInt(dr.GetInt32(1));
                        }
                    }

                    conn.Close();
                    dr.Close();

                    Cursor.Current = Cursors.Default;
                }
            }

            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Шинэчлэх үед алдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #16
0
ファイル: frmMass.cs プロジェクト: ganzoriggnz/CreateItemcode
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            foreach (int i in gvSize.GetSelectedRows())
            {
                if (txtColorPart.Text == null || Core.ToStr(txtColorPart.Text) == "")
                {
                    MessageBox.Show("Үйлдвэрийн өнгө талбар хоосон байна.!", "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtColorPart.Focus();
                    txtColorPart.SelectAll();
                    return;
                }

                clsInfo rw = (clsInfo)gvSize.GetRow(i);
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    clsListItemMain g = new clsListItemMain();
                    g.ID = 0;

                    g.Itemcode = CreateNewCode(rw.Code);

                    if (g.Itemcode.Contains("#"))
                    {
                        MessageBox.Show(g.Itemcode + " гэсэн ITEMCODE Level дутуу оруулсан байна.!", " Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (CheckItemCode(g.Itemcode))
                    {
                        MessageBox.Show(g.Itemcode + " гэсэн ITEMCODE өмнө нь үүсгэсэн байна. Мэдээллээ шалгана уу.!", " Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        int index = gvList.LocateByValue("Itemcode", g.Itemcode);
                        if (index > -1)
                        {
                            gvList.FocusedRowHandle = index;
                        }
                        continue;
                    }

                    if (CheckItemCodeInLocal(g.Itemcode))
                    {
                        MessageBox.Show(g.Itemcode + " гэсэн ITEMCODE доор нэмсэн байна.!", " Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        int index = gvMain.LocateByValue("Itemcode", g.Itemcode);
                        if (index > -1)
                        {
                            gvMain.FocusedRowHandle = index;
                        }
                        continue;
                    }

                    g.Itemcode_eh = txtItemcode.Text;
                    g.Version_eh  = Core.ToInt(txtVer.Text);
                    g.Itemname    = Itemcode.Itemname;
                    g.Itemnameen  = Itemcode.Itemnameen;
                    g.Lev1        = Itemcode.Lev1;
                    g.Lev2        = Itemcode.Lev2;
                    g.Lev3        = Itemcode.Lev3;
                    g.Lev4        = Itemcode.Lev4;
                    g.Lev5        = txtMainColor1.Text;
                    g.Lev6        = Core.ToStr(luplbl6.EditValue);
                    g.Lev7        = Core.ToStr(txtMainColor2.EditValue);
                    g.Lev8        = rw.Code;
                    g.Lev9        = Core.ToStr(luplbl9.EditValue);
                    g.Color1      = Core.ToStr(luplbl5.EditValue);
                    g.Color2      = Core.ToStr(luplbl7.EditValue);


                    g.L1n          = Itemcode.L1n;
                    g.L2n          = Itemcode.L2n;
                    g.L3n          = Itemcode.L3n;
                    g.L6n          = Core.ToStr(luplbl6.Text);
                    g.L8n          = Core.ToStr(rw.Code) + " - " + Core.ToStr(rw.Name);
                    g.L9n          = Core.ToStr(luplbl9.Text);
                    g.Itemcodemain = txtItemcode.Text.Substring(0, 8);
                    g.Colorpart    = Core.ToStr(txtColorPart.Text);

                    list_main.Add(g);

                    gcMain.DataSource       = list_main.ToList();
                    gvMain.FocusedRowHandle = gvMain.DataRowCount - 1;

                    Cursor.Current = Cursors.Default;
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("Aлдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #17
0
 public frmLevelDetail(clsInfo _i)
 {
     InitializeComponent();
     current = _i;
 }
コード例 #18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            clsUser us = (clsUser)gridView1.GetRow(gridView1.FocusedRowHandle);

            if (us == null)
            {
                return;
            }

            if (gridView2.GetSelectedRows().Count() > 0 && MessageBox.Show("Сонгосон бүлгийг нэмэх үү?", "Анхааруулга", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int userID = us.ID;
                Cursor.Current = Cursors.WaitCursor;
                using (var db = new Gobibase())
                {
                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    conn.Open();
                    SqlCommand     cmd = conn.CreateCommand();
                    SqlTransaction transaction;
                    transaction = conn.BeginTransaction("AddTrans");
                    cmd.Parameters.Add("@p1", SqlDbType.Int);
                    cmd.Parameters.Add("@p2", SqlDbType.NVarChar, 50);

                    cmd.Connection  = conn;
                    cmd.Transaction = transaction;

                    try
                    {
                        foreach (int i in gridView2.GetSelectedRows())
                        {
                            clsInfo rw = (clsInfo)gridView2.GetRow(i);
                            cmd.CommandText             = @"INSERT INTO [t_userrole] ([userid],[buleg]) VALUES (@p1,@p2)";
                            cmd.Parameters["@p1"].Value = userID;
                            cmd.Parameters["@p2"].Value = rw.Code;

                            if (lst_UserRole.Where(s => s.Userid == userID && s.Buleg == rw.Code).Count() > 0)
                            {
                                continue;
                            }
                            cmd.ExecuteNonQuery();
                        }

                        transaction.Commit();
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        Cursor.Current = Cursors.Default;
                        MessageBox.Show("Алдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        try
                        {
                            transaction.Rollback();
                        }
                        catch (Exception ex2)
                        {
                            MessageBox.Show("Rollback Exception Type: {0}", ex2.GetType().ToString() + Environment.NewLine + "  Message: " + ex2.Message);
                        }
                    }
                }

                foreach (int i in gridView2.GetSelectedRows())
                {
                    gridView2.UnselectRow(i);
                }

                LoadUserRole();
                gcMain.DataSource = lst_UserRole.Where(s => s.Userid == userID).ToList();
            }
        }
コード例 #19
0
        private void frmUserRole_Load(object sender, EventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            using (var db = new Gobibase())
            {
                SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                SqlCommand    cmd  = new SqlCommand("SELECT [id],[loginName],[uname],[pass],[heltes],[position],[createdate],[role], [workertype] FROM [t_user] where isactive = 1", conn);
                cmd.CommandType = CommandType.Text;
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();

                List <clsUser> lst_user = new List <clsUser>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        clsUser g = new clsUser();
                        g.ID         = dr.IsDBNull(0) ? 0 : Core.ToInt(dr.GetInt32(0));
                        g.LoginName  = dr.IsDBNull(1) ? "" : Core.ToStr(dr.GetString(1));
                        g.Uname      = dr.IsDBNull(2) ? "" : Core.ToStr(dr.GetString(2));
                        g.Pass       = dr.IsDBNull(3) ? "" : Core.ToStr(dr.GetString(3));
                        g.Heltes     = dr.IsDBNull(4) ? "" : Core.ToStr(dr.GetString(4));
                        g.Position   = dr.IsDBNull(5) ? "" : Core.ToStr(dr.GetString(5));
                        g.Createdate = dr.IsDBNull(6) ? DateTime.Now : Core.ToDateTime(dr.GetDateTime(6));
                        g.Role       = dr.IsDBNull(7) ? "" : Core.ToStr(dr.GetString(7));
                        g.Workertype = dr.IsDBNull(8) ? "" : Core.ToStr(dr.GetString(8));
                        lst_user.Add(g);
                    }
                }

                gridControl1.DataSource = lst_user;

                conn.Close();
                dr.Close();

                conn            = new SqlConnection(db.Connection.ConnectionString);
                cmd             = new SqlCommand("select code, name from t_info where l_name = 'Level1' order by sortid", conn);
                cmd.CommandType = CommandType.Text;
                conn.Open();
                dr = cmd.ExecuteReader();

                List <clsInfo> lst_info = new List <clsInfo>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        clsInfo g = new clsInfo();
                        g.Code   = dr.IsDBNull(0) ? "" : Core.ToStr(dr.GetString(0));
                        g.Name   = dr.IsDBNull(1) ? "" : Core.ToStr(dr.GetString(1));
                        g.Nameen = g.Code + " - " + g.Name;
                        lst_info.Add(g);
                    }
                }

                gridControl2.DataSource = lst_info;

                conn.Close();
                dr.Close();
            }

            LoadUserRole();
        }