Beispiel #1
0
        public static int JobDetailInsert(JobDetail detail)
        {
            String sqlstring = string.Format(@"Insert into jobDetail (jobid,specsID,checkTime,ischecked,checkdetailList)
                                               Values({0},{1},'{2}',{3},'{4}')      ",
                                             detail.JobID,
                                             detail.SpecsID,
                                             detail.CheckTime,
                                             detail.isChecked ? 1 : 0,
                                             detail.CheckDetailList);

            DataAccess.ExecuteNonQuery(sqlstring);
            int result = Int32.Parse(DataAccess.ExecuteScalar("select max(id) from jobdetail").ToString());
            int checkP = Int32.Parse(DataAccess.ExecuteScalar(String.Format("select count(*) from jobdetail where jobid={0}", detail.JobID)).ToString());

            DataAccess.ExecuteNonQuery(String.Format("Update JobMain set CheckPosition={1} where id={0}", detail.JobID, checkP));
            return(result);
        }
Beispiel #2
0
        public static JobMain FindJobMainBySQL(String sqlString)
        {
            JobMain result = new JobMain();

            using (IDataReader dr = DataAccess.ExecuteReader(sqlString))
            {
                if (dr.Read())
                {
                    result.ID                = Int32.Parse(dr["ID"].ToString());
                    result.JobDate           = DateTime.Parse(dr["JobDate"].ToString());
                    result.UserID            = Int32.Parse(dr["UserID"].ToString());
                    result.BeginTime         = DateTime.Parse(dr["beginTime"].ToString());
                    result.EndTime           = (dr["EndTime"] == DBNull.Value) ? default(DateTime) : DateTime.Parse(dr["EndTime"].ToString());
                    result.IsUploaded        = (dr["IsUploaded"] == DBNull.Value) ? false : Boolean.Parse(dr["isUploaded"].ToString());
                    result.NeedCheckPosition = (dr["NeedCheckPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["NeedCheckPosition"].ToString());
                    result.CheckPosition     = (dr["CheckPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["CheckPosition"].ToString());
                    result.PassPosition      = (dr["PassPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["PassPosition"].ToString());
                    result.IsFull            = (dr["IsFull"] == DBNull.Value) ? false : Boolean.Parse(dr["IsFull"].ToString());
                    result.TrainCode         = (dr["TrainCode"] == DBNull.Value) ? "" : dr["TrainCode"].ToString();
                    dr.Close();
                }
                else
                {
                    return(null);
                }
            }
            using (IDataReader dr = DataAccess.ExecuteReader(String.Format("Select * from JobDetail where Jobid={0}", result.ID)))
            {
                while (dr.Read())
                {
                    JobDetail item = new JobDetail();
                    item.ID              = Int32.Parse(dr["ID"].ToString());
                    item.JobID           = result.ID;
                    item.SpecsID         = Int32.Parse(dr["SpecsID"].ToString());
                    item.CheckTime       = (dr["CheckTime"] == DBNull.Value) ? default(DateTime) : DateTime.Parse(dr["CheckTime"].ToString());
                    item.isChecked       = (dr["isChecked"] == DBNull.Value) ? false : Boolean.Parse(dr["isChecked"].ToString());
                    item.CheckDetailList = (dr["CheckDetailList"] == DBNull.Value) ? "" : dr["checkDetailList"].ToString();
                    item.BarCode         = (dr["BarCode"] == DBNull.Value) ? "" : dr["BarCode"].ToString();
                    result.Items.Add(item);
                }
                dr.Close();
            }
            return(result);
        }
Beispiel #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvMain.Items)
            {
                SpecsDetail detail = CurrentSpecs.FindByID(Int32.Parse(item.Tag.ToString()));
                detail.isChecked = item.Checked;
            }
            JobDetail jobdetail = CurrentJob.FindBySpecsID(CurrentSpecs.ID);

            if (jobdetail == null)
            {
                jobdetail = new JobDetail();
            }
            jobdetail.JobID           = CurrentJob.ID;
            jobdetail.SpecsID         = CurrentSpecs.ID;
            jobdetail.CheckTime       = DateTime.Now;
            jobdetail.isChecked       = CurrentSpecs.IsCheckAll;
            jobdetail.CheckDetailList = CurrentSpecs.CheckDetailList;
            CurrentJob.Items.Add(jobdetail);
            if (jobdetail.ID == 0)
            {
                jobdetail.ID              = DbFactory.JobDetailInsert(jobdetail);
                CurrentJob.CheckPosition += CurrentJob.CheckPosition;
            }
            else
            {
                DbFactory.JobDetailUpdate(jobdetail);
            }

            //DbFactory.SaveJob(CurrentJob);
            Specs spec = DbFactory.FindBySequence(CurrentSpecs.Sequence + 1);

            if (spec != null)
            {
                CurrentSpecs = spec;
                InitView();
            }
            else
            {
                //work done.
                MessageBox.Show("已经检查到最大序号!");
            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvMain.Items)
            {
                SpecsDetail detail = CurrentSpecs.FindByID(Int32.Parse(item.Tag.ToString()));
                detail.isChecked = item.Checked;

            }
            JobDetail jobdetail = CurrentJob.FindBySpecsID(CurrentSpecs.ID);
            if (jobdetail == null)
            {
                jobdetail = new JobDetail();
            }
            jobdetail.JobID = CurrentJob.ID;
            jobdetail.SpecsID = CurrentSpecs.ID;
            jobdetail.CheckTime = DateTime.Now;
            jobdetail.isChecked = CurrentSpecs.IsCheckAll;
            jobdetail.CheckDetailList = CurrentSpecs.CheckDetailList;
            CurrentJob.Items.Add(jobdetail);
            if (jobdetail.ID == 0)
            {
                jobdetail.ID = DbFactory.JobDetailInsert(jobdetail);
                CurrentJob.CheckPosition += CurrentJob.CheckPosition;
            }
            else
                DbFactory.JobDetailUpdate(jobdetail);

            //DbFactory.SaveJob(CurrentJob);
            Specs spec = DbFactory.FindBySequence(CurrentSpecs.Sequence + 1);
            if (spec != null)
            {
                CurrentSpecs = spec;
                InitView();
            }
            else
            {
                //work done.
                MessageBox.Show("已经检查到最大序号!");
            }
        }
Beispiel #5
0
        public void SetCheckToSpecs(Specs spec)
        {
            JobDetail detail = FindBySpecsID(spec.ID);

            if (detail != null)
            {
                foreach (string kv in detail.CheckDetailList.Split(','))
                {
                    String[] checkresults = kv.Split('=');
                    if (checkresults.Length == 2)
                    {
                        int         spid     = Int32.Parse(checkresults[0]);
                        bool        ispass   = checkresults[1] == "1" ? true : false;
                        SpecsDetail spdetail = spec.FindByID(spid);
                        if (spdetail != null)
                        {
                            spdetail.isChecked = ispass;
                            spdetail.isDone    = true;
                        }
                    }
                }
                spec.IsCheckAll = true;
            }
        }
Beispiel #6
0
        public static JobMain FindJobMainBySQL(String sqlString)
        {
            JobMain result = new JobMain();
            using (IDataReader dr = DataAccess.ExecuteReader(sqlString))
            {
                if (dr.Read())
                {
                    result.ID = Int32.Parse(dr["ID"].ToString());
                    result.JobDate = DateTime.Parse(dr["JobDate"].ToString());
                    result.UserID = Int32.Parse(dr["UserID"].ToString());
                    result.BeginTime = DateTime.Parse(dr["beginTime"].ToString());
                    result.EndTime = (dr["EndTime"] == DBNull.Value) ? default(DateTime) : DateTime.Parse(dr["EndTime"].ToString());
                    result.IsUploaded = (dr["IsUploaded"] == DBNull.Value) ? false : Boolean.Parse(dr["isUploaded"].ToString());
                    result.NeedCheckPosition = (dr["NeedCheckPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["NeedCheckPosition"].ToString());
                    result.CheckPosition = (dr["CheckPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["CheckPosition"].ToString());
                    result.PassPosition = (dr["PassPosition"] == DBNull.Value) ? 0 : Int32.Parse(dr["PassPosition"].ToString());
                    result.IsFull = (dr["IsFull"] == DBNull.Value) ? false : Boolean.Parse(dr["IsFull"].ToString());
                    result.TrainCode = (dr["TrainCode"] == DBNull.Value) ? "" : dr["TrainCode"].ToString();
                    dr.Close();
                }
                else
                    return null;

            }
            using (IDataReader dr = DataAccess.ExecuteReader(String.Format("Select * from JobDetail where Jobid={0}", result.ID)))
            {
                while (dr.Read())
                {
                    JobDetail item = new JobDetail();
                    item.ID = Int32.Parse(dr["ID"].ToString());
                    item.JobID = result.ID;
                    item.SpecsID = Int32.Parse(dr["SpecsID"].ToString());
                    item.CheckTime = (dr["CheckTime"] == DBNull.Value) ? default(DateTime) : DateTime.Parse(dr["CheckTime"].ToString());
                    item.isChecked = (dr["isChecked"] == DBNull.Value) ? false : Boolean.Parse(dr["isChecked"].ToString());
                    item.CheckDetailList = (dr["CheckDetailList"] == DBNull.Value) ? "" : dr["checkDetailList"].ToString();
                    item.BarCode = (dr["BarCode"] == DBNull.Value) ? "" : dr["BarCode"].ToString();
                    result.Items.Add(item);
                }
                dr.Close();
            }
            return result;
        }
Beispiel #7
0
 public static int JobDetailUpdate(JobDetail detail)
 {
     return DataAccess.ExecuteNonQuery(String.Format(@"Update jobDetail set ischecked={0},checkTime='{1}',checkDetailList=
                                                         '{2}',BarCode='{5}' where jobid={3} and specsID={4}    ",
                                                           detail.isChecked ? 1 : 0,
                                                           detail.CheckTime,
                                                           detail.CheckDetailList,
                                                           detail.JobID,
                                                           detail.SpecsID,
                                                           detail.BarCode));
 }
Beispiel #8
0
 public static int JobDetailInsert(JobDetail detail)
 {
     String sqlstring = string.Format(@"Insert into jobDetail (jobid,specsID,checkTime,ischecked,checkdetailList,barCode)
                                        Values({0},{1},'{2}',{3},'{4}','{5}')      ",
                                        detail.JobID,
                                        detail.SpecsID,
                                        detail.CheckTime,
                                        detail.isChecked ? 1 : 0,
                                        detail.CheckDetailList,
                                        detail.BarCode);
     DataAccess.ExecuteNonQuery(sqlstring);
     int result = Int32.Parse(DataAccess.ExecuteScalar("select max(id) from jobdetail").ToString());
     int checkP = Int32.Parse(DataAccess.ExecuteScalar(String.Format("select count(*) from jobdetail where jobid={0}",detail.JobID)).ToString());
     sqlstring = String.Format("Update JobMain set CheckPosition={1} where id={0}", detail.JobID, checkP);
     if (detail.isChecked)
         sqlstring = String.Format("Update JobMain set CheckPosition={1},PassPosition=PassPosition+1 where id={0}", detail.JobID, checkP);
     DataAccess.ExecuteNonQuery(sqlstring);
     return result;
 }