Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        ///
        public int add(FishEntity.ContractDetailVo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_ssss (productid,loadingcode,loadingdate,quantity,unitprice,state,weight,contractno,contractdate,getw,getq,yifang,saleman,cid,linkman,isdelete,companyid,createman) VALUES  ");
            strSql.Append("(@productid,@loadingcode,@loadingdate,@quantity,@unitprice,@state,@weight,@contractno,@contractdate,@getw,@getq,@yifang,@saleman,@cid,@linkman,@isdelete,@companyid,@createman) ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@productid",    MySqlDbType.Int32,   11),
                new MySqlParameter("@loadingcode",  MySqlDbType.VarChar, 20),
                new MySqlParameter("@loadingdate",  MySqlDbType.Date,     0),
                new MySqlParameter("@quantity",     MySqlDbType.Decimal, 12),
                new MySqlParameter("@unitprice",    MySqlDbType.Decimal, 10),
                new MySqlParameter("@state",        MySqlDbType.VarChar, 45),
                new MySqlParameter("@weight",       MySqlDbType.Decimal, 45),
                new MySqlParameter("@contractno",   MySqlDbType.VarChar, 45),
                new MySqlParameter("@contractdate", MySqlDbType.Date,    45),
                new MySqlParameter("@getw",         MySqlDbType.Decimal, 12),
                new MySqlParameter("@getq",         MySqlDbType.Decimal, 12),
                new MySqlParameter("@yifang",       MySqlDbType.VarChar, 45),
                new MySqlParameter("@saleman",      MySqlDbType.VarChar, 45),
                new MySqlParameter("@cid",          MySqlDbType.Int32,   11),
                new MySqlParameter("@linkman",      MySqlDbType.VarChar, 45),
                new MySqlParameter("@isdelete",     MySqlDbType.Int32,   10),
                new MySqlParameter("@createman",    MySqlDbType.VarChar, 45),
                new MySqlParameter("companyid",     MySqlDbType.Int32, 10)
            };
            parameters[0].Value  = model.productid;
            parameters[1].Value  = model.loadingcode;
            parameters[2].Value  = model.loadingdate;
            parameters[3].Value  = model.quantity;
            parameters[4].Value  = model.unitprice;
            parameters[5].Value  = model.state;
            parameters[6].Value  = model.weight;
            parameters[7].Value  = model.contractno;
            parameters[8].Value  = model.contractdate;
            parameters[9].Value  = model.getw;
            parameters[10].Value = model.getq;
            parameters[11].Value = model.yifang;
            parameters[12].Value = model.saleman;
            parameters[13].Value = model.cid;
            parameters[14].Value = model.linkman;
            parameters[15].Value = model.isdelete;
            parameters[16].Value = model.createman;
            parameters[17].Value = model.companyid;
            int id = MySqlHelper.ExecuteSqlReturnId(strSql.ToString(), parameters);

            return(id);
        }
Example #2
0
 public bool Update1(FishEntity.ContractDetailVo model)
 {
     return(dal.Update1(model));
 }
Example #3
0
 public int add(FishEntity.ContractDetailVo model)
 {
     return(dal.add(model));
 }
Example #4
0
        public FishEntity.ContractDetailVo DataRowToModel1(DataRow row)
        {
            FishEntity.ContractDetailVo model = new FishEntity.ContractDetailVo();
            if (row != null)
            {
                if (row["productid"] != null && row["productid"].ToString() != "")
                {
                    model.productid = int.Parse(row["productid"].ToString());
                }
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["contractno"] != null)
                {
                    model.contractno = row["contractno"].ToString();
                }
                if (row["loadingcode"] != null)
                {
                    model.loadingcode = row["loadingcode"].ToString();
                }
                //if (row["signaddress"] != null)
                //{
                //    model.signaddress = row["signaddress"].ToString();
                //}
                if (row["quantity"] != null && row["quantity"].ToString() != "")
                {
                    model.quantity = decimal.Parse(row["quantity"].ToString());
                }

                if (row["companyid"] != null && row["companyid"].ToString() != "")
                {
                    model.companyid = int.Parse(row["companyid"].ToString());
                }
                //if (row["yifangcode"] != null)
                //{
                //    model.yifangcode = row["yifangcode"].ToString();
                //}
                //if (row["yifang"] != null)
                //{
                //    model.yifang = row["yifang"].ToString();
                //}
                //if (row["yiduanzhuang"] != null)
                //{
                //    model.yiduanzhuang = row["yiduanzhuang"].ToString();
                //}
                if (row["createman"] != null)
                {
                    model.createman = row["createman"].ToString();
                }
                if (row["cid"] != null || row["cid"].ToString() != "")
                {
                    model.cid = int.Parse(row["cid"].ToString());
                }
                if (row["linkman"] != null || row["linkman"].ToString() != "")
                {
                    model.linkman = row["linkman"].ToString();
                }
                //if (row["check3"] != null)
                //{
                //    model.check3 = row["check3"].ToString();
                //}
                if (row["contractdate"] != null)
                {
                    model.contractdate = DateTime.Parse(row["contractdate"].ToString());
                }
                if (row["contractno"] != null)
                {
                    model.contractno = row["contractno"].ToString();
                }
                if (row["getw"] != null || row["getw"].ToString() != "")
                {
                    model.getw = decimal.Parse(row["getw"].ToString());
                }
                if (row["getq"] != null || row["getq"].ToString() != "")
                {
                    model.getq = decimal.Parse(row["getq"].ToString());
                }
                //if (row["package"] != null)
                //{
                //    model.package = row["package"].ToString();
                //}
                if (row["weight"] != null || row["weight"].ToString() != "")
                {
                    model.weight = decimal.Parse(row["weight"].ToString());
                }
                if (row["yifang"] != null)
                {
                    model.yifang = row["yifang"].ToString();
                }
                if (row["isdelete"] != null || row["isdelete"].ToString() != "")
                {
                    model.isdelete = int.Parse(row["isdelete"].ToString());
                }
                //if (row["bank"] != null)
                //{
                //    model.bank = row["bank"].ToString();
                //}
                //if (row["bankaccount"] != null)
                //{
                //    model.bankaccount = row["bankaccount"].ToString();
                //}
                //if (row["resolve"] != null)
                //{
                //    model.resolve = row["resolve"].ToString();
                //}
                //if (row["time1"] != null)
                //{
                //    model.time1 = row["time1"].ToString();
                //}
                //if (row["time2"] != null)
                //{
                //    model.time2 = row["time2"].ToString();
                //}
                //if (row["time3"] != null)
                //{
                //    model.time3 = row["time3"].ToString();
                //}
                //if (row["time4"] != null)
                //{
                //    model.time4 = row["time4"].ToString();
                //}
                //if (row["maifangcode"] != null)
                //{
                //    model.maifangcode = row["maifangcode"].ToString();
                //}
                //if (row["maifang"] != null)
                //{
                //    model.maifang = row["maifang"].ToString();
                //}
                //if (row["maifangaddress"] != null)
                //{
                //    model.maifangaddress = row["maifangaddress"].ToString();
                //}
                //if (row["maifangtelephone"] != null)
                //{
                //    model.maifangtelephone = row["maifangtelephone"].ToString();
                //}
                //if (row["maifangfox"] != null)
                //{
                //    model.maifangfox = row["maifangfox"].ToString();
                //}
                //if (row["yifangaddress"] != null)
                //{
                //    model.yifangaddress = row["yifangaddress"].ToString();
                //}
                //if (row["yifangtelephone"] != null)
                //{
                //    model.yifangtelephone = row["yifangtelephone"].ToString();
                //}
                //if (row["yifangfox"] != null)
                //{
                //    model.yifangfox = row["yifangfox"].ToString();
                //}
                if (row["loadingdate"] != null || row["loadingdate"].ToString() != "")
                {
                    model.loadingdate = DateTime.Parse(row["loadingdate"].ToString());
                }
                if (row["unitprice"] != null || row["unitprice"].ToString() != "")
                {
                    model.unitprice = decimal.Parse(row["unitprice"].ToString());
                }
                if (row["saleman"] != null)
                {
                    model.saleman = row["saleman"].ToString();
                }
                if (row["state"].ToString() != null)
                {
                    model.state = row["state"].ToString();
                }
            }
            return(model);
        }
Example #5
0
        public bool Update1(FishEntity.ContractDetailVo model)
        {
            StringBuilder strSsql = new StringBuilder();

            strSsql.Append(" update t_ssss set  ");
            //productid,loadingcode,loadingdate,quantity,unitprice,state,weight,contractno,contractdate,getw,getq,yifang,saleman,cid,linkman,isdelete
            strSsql.Append(" productid=@productid, ");
            strSsql.Append(" loadingcode=@loadingcode, ");
            strSsql.Append(" loadingdate=@loadingdate, ");
            strSsql.Append(" quantity=@quantity, ");
            strSsql.Append(" unitprice=@unitprice, ");
            strSsql.Append(" state=@state, ");
            strSsql.Append(" weight=@weight, ");
            strSsql.Append(" contractno=@contractno, ");
            strSsql.Append(" contractdate=@contractdate, ");
            strSsql.Append(" getw=@getw, ");
            strSsql.Append(" getq=@getq, ");
            strSsql.Append(" yifang=@yifang, ");
            strSsql.Append(" createman=@createman, ");
            strSsql.Append(" cid=@cid, ");
            strSsql.Append(" linkman=@linkman, ");
            strSsql.Append(" isdelete=@isdelete, ");
            strSsql.Append(" companyid=@companyid ");
            strSsql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@productid",    MySqlDbType.Int32,   11),
                new MySqlParameter("@loadingcode",  MySqlDbType.VarChar, 20),
                new MySqlParameter("@loadingdate",  MySqlDbType.Date,     0),
                new MySqlParameter("@quantity",     MySqlDbType.Decimal, 12),
                new MySqlParameter("@unitprice",    MySqlDbType.Decimal, 10),
                new MySqlParameter("@state",        MySqlDbType.VarChar, 45),
                new MySqlParameter("@weight",       MySqlDbType.Decimal, 45),
                new MySqlParameter("@contractno",   MySqlDbType.VarChar, 45),
                new MySqlParameter("@contractdate", MySqlDbType.Date,    45),
                new MySqlParameter("@getw",         MySqlDbType.Decimal, 12),
                new MySqlParameter("@getq",         MySqlDbType.Decimal, 12),
                new MySqlParameter("@yifang",       MySqlDbType.VarChar, 45),
                new MySqlParameter("@createman",    MySqlDbType.VarChar, 45),
                new MySqlParameter("@cid",          MySqlDbType.Int32,   11),
                new MySqlParameter("@linkman",      MySqlDbType.VarChar, 45),
                new MySqlParameter("@isdelete",     MySqlDbType.Int32,   10),
                new MySqlParameter("@companyid",    MySqlDbType.Int32,   10),
                new MySqlParameter("@id",           MySqlDbType.Int32, 10)
            };
            parameters[0].Value  = model.productid;
            parameters[1].Value  = model.loadingcode;
            parameters[2].Value  = model.loadingdate;
            parameters[3].Value  = model.quantity;
            parameters[4].Value  = model.unitprice;
            parameters[5].Value  = model.state;
            parameters[6].Value  = model.weight;
            parameters[7].Value  = model.contractno;
            parameters[8].Value  = model.contractdate;
            parameters[9].Value  = model.getw;
            parameters[10].Value = model.getq;
            parameters[11].Value = model.yifang;
            parameters[12].Value = model.createman;
            parameters[13].Value = model.cid;
            parameters[14].Value = model.linkman;
            parameters[15].Value = model.isdelete;
            parameters[16].Value = model.companyid;
            parameters[17].Value = model.id;
            int rows = MySqlHelper.ExecuteSql(strSsql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        protected void Save()
        {
            if (Check() == false)
            {
                return;
            }

            dataGridView1.EndEdit();

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

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                FishEntity.ContractDetailVo quote = new FishEntity.ContractDetailVo();
                int productid = 0;
                int packages  = 0;
                //quote.productid = _productId;
                quote.loadingcode = row.Cells["loadingcode"].Value == null ? "" : row.Cells["loadingcode"].Value.ToString();

                int id = 0;
                if (row.Cells["id"].EditedFormattedValue == null)
                {
                    id = 0;
                }
                else
                {
                    int.TryParse(row.Cells["id"].EditedFormattedValue.ToString(), out id);
                }
                quote.id         = id;
                quote.productid  = _productId;
                quote.isfinished = 0;
                quote.saleman    = row.Cells["saleman"].Value == null ? "" : row.Cells["saleman"].ToString();
                quote.state      = row.Cells["state"].EditedFormattedValue == null ? string.Empty : row.Cells["state"].EditedFormattedValue.ToString();
                int companyid = 0;
                int.TryParse(row.Cells["companyid"].Value == null ? "0" : row.Cells["companyid"].Value.ToString(), out companyid);
                quote.companyid = companyid;
                //quote.yifang = row.Cells["yifang"].Value == null ? string.Empty : row.Cells["yifang"].ToString();
                quote.yifang     = row.Cells["yifang"].EditedFormattedValue == null ? string.Empty : row.Cells["yifang"].EditedFormattedValue.ToString();
                quote.contractno = row.Cells["contractno"].EditedFormattedValue == null ? "" : row.Cells["contractno"].EditedFormattedValue.ToString();
                quote.linkman    = row.Cells["linkman"].EditedFormattedValue == null ? string.Empty : row.Cells["linkman"].EditedFormattedValue.ToString();
                int no = 0;
                int.TryParse(row.Cells["no"].Value == null ? "1" : row.Cells["no"].Value.ToString(), out no);
                quote.cid = no;
                DateTime temp;
                DateTime.TryParse(row.Cells["contractdate"].EditedFormattedValue.ToString(), out temp);
                quote.contractdate = temp;
                DateTime.TryParse(row.Cells["loadingdate"].EditedFormattedValue.ToString(), out temp);
                quote.loadingdate = temp;
                decimal temp2;
                decimal.TryParse(row.Cells["quantity"].EditedFormattedValue == null ? "0" : row.Cells["quantity"].EditedFormattedValue.ToString(), out temp2);
                //decimal.TryParse(row.Cells["quantity"].EditedFormattedValue.ToString(), out temp2);
                quote.quantity = temp2;
                decimal.TryParse(row.Cells["unitprice"].EditedFormattedValue.ToString(), out temp2);
                quote.unitprice = temp2;
                decimal.TryParse(row.Cells["weight"].EditedFormattedValue == null ? "0" : row.Cells["weight"].EditedFormattedValue.ToString(), out temp2);
                quote.weight = temp2;
                decimal.TryParse(row.Cells["getw"].EditedFormattedValue == null ? "0" : row.Cells["getw"].EditedFormattedValue.ToString(), out temp2);
                quote.getw = temp2;
                decimal.TryParse(row.Cells["getq"].EditedFormattedValue == null ? "0" : row.Cells["getq"].EditedFormattedValue.ToString(), out temp2);
                quote.getq = temp2;

                if (row.Cells["isdelete"].Value == null || row.Cells["isdelete"].Value.ToString() == "")
                {
                    quote.isdelete = 0;
                }
                else
                {
                    quote.isdelete = row.Cells["isdelete"].Value.ToString().Equals("有效") ? 0 : 1;
                }

                listNews.Add(quote);
            }

            List <FishEntity.ContractDetailVo> listsource = _bll.GetModelList1(" productid = " + _productId);

            if (listsource != null)
            {
                foreach (ContractDetailVo item in listsource)
                {
                    bool isExist = listNews.Exists((i) => { return(i.id == item.id); });
                    if (isExist == false)
                    {
                        bool isDelte = _bll.Delete1(item.id);
                    }
                    //break;
                }
            }
            DateTime loadingdate;
            decimal  getw         = 0;
            decimal  unitprice    = 0;
            decimal  quantity     = 0;
            decimal  weight       = 0;
            int      latequantity = 0;
            DateTime latestTime   = DateTime.MinValue;
            string   company      = string.Empty;
            string   customer     = string.Empty;

            foreach (ContractDetailVo item in listNews)
            {
                if (item.id == 0)
                {//createman
                    item.saleman     = FishEntity.Variable.User.username;
                    item.createman   = item.saleman;
                    item.loadingdate = item.loadingdate;
                    item.weight      = item.weight;
                    item.companyid   = item.companyid;
                    item.linkman     = item.linkman;
                    item.unitprice   = item.unitprice;
                    item.quantity    = item.quantity;
                    //item.packages = item.packages;
                    item.state        = item.state;
                    item.contractno   = item.contractno;
                    item.contractdate = item.contractdate;
                    item.getw         = item.getw;
                    item.getq         = item.getq;
                    item.yifang       = item.yifang;
                    item.loadingcode  = item.loadingcode;
                    item.cid          = item.cid;
                    //company = item.company;
                    int id = _bll.add(item);
                    if (id > 0)
                    {
                        item.id = id;

                        string   qDateStr = item.loadingdate.ToString("yyyy-MM-dd");
                        DateTime qDate    = DateTime.Parse(qDateStr);
                        if (qDate > latestTime)
                        {
                            latestTime = qDate;
                            getw       = item.getw;
                            unitprice  = item.unitprice;
                            quantity   = item.quantity;
                            weight     = item.weight;
                            //latequantity = item.quantity;
                            company = item.company;
                            //customer = item.customer;
                        }
                    }
                }
                else
                {
                    item.saleman     = FishEntity.Variable.User.username;
                    item.loadingdate = item.loadingdate;
                    item.weight      = item.weight;
                    item.linkman     = item.linkman;
                    item.unitprice   = item.unitprice;
                    item.quantity    = item.quantity;
                    item.companyid   = item.companyid;
                    //item.packages = item.packages;
                    item.state        = item.state;
                    item.contractno   = item.contractno;
                    item.contractdate = item.contractdate;
                    item.getw         = item.getw;
                    item.getq         = item.getq;
                    item.yifang       = item.yifang;
                    item.loadingcode  = item.loadingcode;
                    item.cid          = item.cid;
                    //item.linkman = FishEntity.Variable.User.username;
                    bool isUpdate = _bll.Update1(item);
                    //if (isUpdate)
                    //{
                    //    string qTimeStr = item.spotdate.ToString("yyyy-MM-dd") + " " + item.spottime.ToString("HH:mm:ss");
                    //    DateTime qTime = DateTime.Parse(qTimeStr);
                    //    if (qTime > latestTime)
                    //    {
                    //        latestTime = qTime;
                    //        latestprice = item.dollars;
                    //        latedollars = item.dollars;
                    //        latermb = item.rmb;
                    //        laterate = item.rate;
                    //        lateweight = item.weight;
                    //        latequantity = item.quantity;
                    //        company = item.company;
                    //        customer = item.customer;
                    //    }
                    //}
                }
            }

            //重新刷新数据
            List <FishEntity.ContractDetailVo> list = _bll.GetModelList1(" productid=" + _productId);

            SetContractDetail(list);
        }