コード例 #1
0
        protected void GetInfo(List <FishEntity.CallRecordsEntity> list)
        {
            if (list == null)
            {
                return;
            }
            FishBll.Bll.CallRecordsDetailBll detailBll = new FishBll.Bll.CallRecordsDetailBll();
            foreach (FishEntity.CallRecordsEntity item in list)
            {
                string bj = "";
                string cg = "";
                List <FishEntity.CallRecordsDetailEntnty> details = detailBll.GetModelList(" callrecordid=" + item.id);
                if (details != null)
                {
                    foreach (FishEntity.CallRecordsDetailEntnty de in details)
                    {
                        if (string.IsNullOrEmpty(bj) == false)
                        {
                            bj += ",";
                        }
                        bj += de.specification + de.quoteprice;
                        if (string.IsNullOrEmpty(cg) == false)
                        {
                            cg += "\r\n";
                        }
                        cg += de.orderstate + ":" + de.weight + de.specification + de.quoteprice;
                    }
                }

                item.quoteInfo = bj;
                item.buyInfo   = cg;
            }
        }
コード例 #2
0
        protected void AddDetail(int callrecordid, bool isAdd)
        {
            dataGridView1.EndEdit();

            List <FishEntity.CallRecordsDetailEntnty> listNews = new List <FishEntity.CallRecordsDetailEntnty>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                FishEntity.CallRecordsDetailEntnty item = new FishEntity.CallRecordsDetailEntnty();
                int id = 0;
                int.TryParse(row.Cells["id"].Value == null ? "0" : row.Cells["id"].Value.ToString(), out id);
                item.id = id;
                int no = 0;
                int.TryParse(row.Cells["no"].Value == null ? "0" : row.Cells["no"].Value.ToString(), out no);
                item.no = no;

                item.nature        = row.Cells["nature"].Value == null ? string.Empty : row.Cells["nature"].Value.ToString();
                item.brand         = row.Cells["brand"].Value == null ? string.Empty : row.Cells["brand"].Value.ToString();
                item.specification = row.Cells["specification"].Value == null ? string.Empty : row.Cells["specification"].Value.ToString();
                item.orderstate    = row.Cells["orderstate"].Value == null ? string.Empty : row.Cells["orderstate"].Value.ToString();
                item.callrecordid  = callrecordid;

                item.domestic_amine      = GetDecimal(row.Cells["domestic_amine"].Value);
                item.domestic_aminototal = GetDecimal(row.Cells["domestic_aminototal"].Value);
                item.domestic_fat        = GetDecimal(row.Cells["domestic_fat"].Value);
                item.domestic_graypart   = GetDecimal(row.Cells["domestic_graypart"].Value);
                item.domestic_lysine     = GetDecimal(row.Cells["domestic_lysine"].Value);
                item.domestic_methionine = GetDecimal(row.Cells["domestic_methionine"].Value);
                item.domestic_protein    = GetDecimal(row.Cells["domestic_protein"].Value);
                item.domestic_sandsalt   = GetDecimal(row.Cells["domestic_sandsalt"].Value);
                item.domestic_sour       = GetDecimal(row.Cells["domestic_sour"].Value);
                item.domestic_tvn        = GetDecimal(row.Cells["domestic_tvn"].Value);
                item.paymethod           = row.Cells["paymethod"].Value == null ? string.Empty : row.Cells["paymethod"].Value.ToString();
                item.payperiod           = row.Cells["payperiod"].Value == null ? string.Empty : row.Cells["payperiod"].Value.ToString();
                item.quoteprice          = GetDecimal(row.Cells["quoteprice"].Value);
                item.saleprice           = GetDecimal(row.Cells["saleprice"].Value);
                item.weight = GetDecimal(row.Cells["weight"].Value);

                listNews.Add(item);
            }


            if (isAdd == false)
            {
                List <FishEntity.CallRecordsDetailEntnty> listsource = _detailBll.GetModelList(" callrecordid=" + callrecordid);
                if (listsource != null)
                {
                    foreach (FishEntity.CallRecordsDetailEntnty item in listsource)
                    {
                        bool isExist = listNews.Exists((i) => { return(i.id == item.id); });
                        if (isExist == false)
                        {
                            bool isDelete = _detailBll.Delete(item.id);
                        }
                    }
                }
            }

            foreach (FishEntity.CallRecordsDetailEntnty item in listNews)
            {
                if (item.id == 0)
                {
                    int id = _detailBll.Add(item);
                    if (id > 0)
                    {
                        item.id = id;
                    }
                }
                else
                {
                    _detailBll.Update(item);
                }
            }

            _detail = listNews;

            dataGridView1.DataSource = _detail;
        }