Exemple #1
0
    public List <clsProgram> GetProgram(string programID)
    {
        clsProgram        pClass      = new clsProgram();
        List <clsProgram> programList = new List <clsProgram>();

        try
        {
            int  id = 0;
            bool b  = int.TryParse(programID, out id);
            pClass.ProgramID = id;

            programList = pClass.getPrograms();
        }
        catch (Exception er)
        {
            programList.Add(new clsProgram {
                ErrorMessage = er.Message.ToString()
            });
        }
        return(programList);
    }
        private void LoadProVersion()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                using (var db = new Gobibase())
                {
                    lst_pro_version.Clear();

                    SqlConnection conn = new SqlConnection(db.Connection.ConnectionString);
                    SqlCommand    cmd  = new SqlCommand(@"SELECT p.[id],[proman],p.[itemcode],[startdate],[givedate]
,[version],[tuluv],[car_typeid],[car_markid],[detailnum],[progunelgee],[suljihtime],u.uname,ct.name as cartype, cm.name as carmark,profilename,hurd,sizetoo
FROM [t_programist] as p 
inner join dbo.t_main AS m ON p.itemcode = m.itemcode AND m.zagvartype = N'Эх загвар'
left join t_user as u on u.id = p.proman 
left outer join t_info as ct on ct.id = p.car_typeid and ct.l_name='cartype'
left outer join t_info as cm on cm.id = p.car_markid and cm.l_name='carmark' order by p.itemcode;", conn);
                    cmd.CommandType = CommandType.Text;
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            clsProgram g = new clsProgram();
                            g.ID          = dr.IsDBNull(0) ? 0 : Core.ToInt(dr.GetInt32(0));
                            g.Proman      = dr.IsDBNull(1) ? 0 : Core.ToInt(dr.GetInt32(1));
                            g.Itemcode    = dr.IsDBNull(2) ? "" : Core.ToStr(dr.GetString(2));
                            g.Startdate   = dr.IsDBNull(3) ? "" : Core.ToStr(dr.GetString(3));
                            g.Givedate    = dr.IsDBNull(4) ? "" : Core.ToStr(dr.GetString(4));
                            g.Version     = dr.IsDBNull(5) ? 0 : Core.ToInt(dr.GetInt32(5));
                            g.Tuluv       = dr.IsDBNull(6) ? "" : Core.ToStr(dr.GetString(6));
                            g.Car_typeid  = dr.IsDBNull(7) ? 0 : Core.ToInt(dr.GetInt32(7));
                            g.Car_markid  = dr.IsDBNull(8) ? 0 : Core.ToInt(dr.GetInt32(8));
                            g.Detailnum   = dr.IsDBNull(9) ? "" : Core.ToStr(dr.GetString(9));
                            g.Progunelgee = dr.IsDBNull(10) ? "" : Core.ToStr(dr.GetString(10));
                            g.Suljihtime  = dr.IsDBNull(11) ? "" : Core.ToStr(dr.GetString(11));
                            g.Proname     = dr.IsDBNull(12) ? "" : Core.ToStr(dr.GetString(12));
                            g.Cartype     = dr.IsDBNull(13) ? "" : Core.ToStr(dr.GetString(13));
                            g.Carmark     = dr.IsDBNull(14) ? "" : Core.ToStr(dr.GetString(14));
                            g.Profilename = dr.IsDBNull(15) ? "" : Core.ToStr(dr.GetString(15));
                            g.Hurd        = dr.IsDBNull(16) ? "" : Core.ToStr(dr.GetString(16));
                            g.Sizetoo     = dr.IsDBNull(17) ? "" : Core.ToStr(dr.GetString(17));
                            lst_pro_version.Add(g);
                        }
                    }

                    conn.Close();
                    dr.Close();
                    Cursor.Current = Cursors.Default;

                    gridControl1.DataSource = lst_pro_version.ToList();
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Aлдаа гарлаа!" + Environment.NewLine + ex.Message, "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }