Example #1
0
 private void UpdateCheckListFromModel(CheckList target, CheckListModel source)
 {
     target.CheckListId       = source.CheckListId;
     target.CheckListGuid     = source.CheckListGuid;
     target.CheckListName     = source.CheckListName;
     target.CheckListIsActive = source.CheckListIsActive;
 }
        public ActionResult Index(int?month, int?year)
        {
            var today = DateTime.Today;
            var dates =
                from e in dataContext.CarbonEmissionEntries
                select e.EntryDate;

            if (!dates.Any())
            {
                dates = (new[] { today }).AsQueryable();
            }
            var minDate = dates.Min();
            var maxDate = dates.Max();

            month = (month ?? (today.Month - 1)) % 12;
            year  = year ?? today.Year;
            year  = (year.Value > maxDate.Year) ? maxDate.Year : year;
            year  = (year.Value < minDate.Year) ? minDate.Year : year;
            var model = new CheckListModel
            {
                MaxYearInRange = maxDate.Year,
                MinYearInRange = minDate.Year,
                SelectedMonth  = month.Value,
                SelectedYear   = year.Value
            };

            return(View(model));
        }
Example #3
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            this.dataGridView1.CurrentCell = null;
            if (this.dataGridView1.RowCount == 0)
            {
                MessageBox.Show("请添加数据!");
                return;
            }
            CheckListModel obj = new CheckListModel();

            obj.user    = PropertyClass.UserId;
            obj.list_sm = new List <StockMateriel>();
            for (int i = this.dataGridView1.RowCount; i > 0; i--)
            {
                StockMateriel sm = new StockMateriel();
                if (this.dataGridView1.Rows[i - 1].Cells["batchnum"].Value != DBNull.Value)
                {
                    sm.batchnum = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["batchnum"].Value);
                }
                sm.materiel = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["materiel"].Value);
                if (this.dataGridView1.Rows[i - 1].Cells["position"].Value != DBNull.Value)
                {
                    sm.position = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["position"].Value);
                }
                sm.warehouse    = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["warehouse"].Value);
                sm.truequantity = Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["avaquantity"].Value);
                sm.supplier     = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["supplierId"].Value);
                if (this.dataGridView1.Rows[i - 1].Cells["combination"].Value != DBNull.Value)
                {
                    sm.combination = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["combination"].Value);
                }
                obj.list_sm.Add(sm);
            }

            var msg = ctrl.add(obj);

            if (msg.Code == 0)
            {
                System.Data.DataTable dtcheck = ctrl.getlastinsert(PropertyClass.UserId);
                if (dtcheck.Rows.Count > 0)
                {
                    label2.Visible   = true;
                    label3.Text      = dtcheck.Rows[0]["num"].ToString();
                    label4.Visible   = true;
                    label5.Text      = dtcheck.Rows[0]["date"].ToString();
                    this.label6.Text = dtcheck.Rows[0]["id"].ToString();
                }


                toolStripButton1.Enabled = false;
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton4.Enabled = true;
                MessageBox.Show(msg.Msg);
            }
            else
            {
                MessageBox.Show(msg.Msg);
            }
        }
Example #4
0
        public async Task <int> DeleteCheckListAsync(CheckListModel model)
        {
            var documentType = new CheckList {
                CheckListId = model.CheckListId
            };

            using (var dataService = DataServiceFactory.CreateDataService())
            {
                return(await dataService.DeleteCheckListAsync(documentType));
            }
        }
Example #5
0
        public static CheckListModel CreateCheckListModelAsync(CheckList source, bool includeAllFields)
        {
            var model = new CheckListModel()
            {
                CheckListId       = source.CheckListId,
                CheckListGuid     = source.CheckListGuid,
                CheckListName     = source.CheckListName,
                CheckListIsActive = source.CheckListIsActive
            };

            return(model);
        }
        public async Task <CheckListModel> GetCheckListTreeAsync(Guid id)
        {
            var checkList = await Repository.GetAsync(id);

            var model = new CheckListModel()
            {
                Id          = checkList.Id,
                Name        = checkList.Name,
                Description = checkList.Description,
            };

            FillTreeLevel(checkList.Items, model.Items, null);

            return(model);
        }
Example #7
0
        public async Task <int> AddCheckListAsync(CheckListModel model)
        {
            long id = model.CheckListId;

            using (var dataService = DataServiceFactory.CreateDataService())
            {
                var documentType = new CheckList();
                if (documentType != null)
                {
                    UpdateCheckListFromModel(documentType, model);
                    documentType.CheckListGuid = Guid.NewGuid();
                    await dataService.AddCheckListAsync(documentType);

                    model.Merge(await GetCheckListAsync(dataService, documentType.CheckListId));
                }
                return(0);
            }
        }
Example #8
0
        internal CheckListDTO AddCheckList(string id, string name)
        {
            CheckListModel model = new CheckListModel
            {
                Name       = name,
                CheckItems = new List <ObjectId>(),
            };

            db_.GetCollection <CheckListModel>("CheckLists").InsertOne(model);

            var filter = Builders <CardModel> .Filter.Eq("_id", new ObjectId(id));

            var update = Builders <CardModel> .Update.Push(card => card.CheckLists, model.Id);

            db_.GetCollection <CardModel>("Cards").UpdateOne(filter, update);
            return(new CheckListDTO
            {
                ID = model.Id.ToString(),
                Name = model.Name,
                CheckItems = new List <CheckItemDTO>()
            });
        }
Example #9
0
        public MessageModel add(CheckListModel ck)
        {
            List <string> sqlList = new List <string>();
            string        num     = "(SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_NAME = 'checklist')";

            string sqlOrder = "insert into checklist (user,num) " +
                              " values(@user, concat('CHECK',LPAD(" + num + ",9,'0')));";

            string sqlMat = "insert into checkmateriel (checklist,supplier,materiel,truequantity,warehouse,batchnum,position,combination) values ";

            for (int i = 0; i < ck.list_sm.Count; i++)
            {
                if (i != 0)
                {
                    sqlMat += ",";
                }
                sqlMat += " (last_insert_id(),'" + ck.list_sm[i].supplier + "','" + ck.list_sm[i].materiel + "','" + ck.list_sm[i].truequantity + "','" + ck.list_sm[i].warehouse + "',";
                if (ck.list_sm[i].batchnum != null)
                {
                    sqlMat += "'" + ck.list_sm[i].batchnum + "',";
                }
                else
                {
                    sqlMat += "null,";
                }
                if (ck.list_sm[i].position != null)
                {
                    sqlMat += "'" + ck.list_sm[i].position + "',";
                }
                else
                {
                    sqlMat += "null,";
                }
                if (ck.list_sm[i].combination != null)
                {
                    sqlMat += "'" + ck.list_sm[i].combination + "')";
                }
                else
                {
                    sqlMat += "null)";
                }
            }

            sqlList.Add(sqlOrder);
            sqlList.Add(sqlMat);

            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("@user", ck.user);

            bool         result = h.ExcuteTransaction(sqlList, paras);
            MessageModel msg    = new MessageModel();

            if (result == true)
            {
                msg = new MessageModel(0, "新建成功");
            }
            else
            {
                msg = new MessageModel(10005, "新建失败");
            }
            return(msg);
        }