Ejemplo n.º 1
0
 void edit(FishEntity.PackingWeightListEntity list, Hashtable SQLString, StringBuilder strSql)
 {
     strSql = new StringBuilder();
     strSql.Append("update t_PackingWeightList set ");
     strSql.Append("CONTANERNO=@CONTANERNO, ");
     strSql.Append("QUANTITYOFBAGS=@QUANTITYOFBAGS, ");
     strSql.Append("GROSSWEIGHT=@GROSSWEIGHT, ");
     strSql.Append("NETWEIGHT=@NETWEIGHT, ");
     strSql.Append("modifyman=@modifyman, ");
     strSql.Append("modifytime=@modifytime ");
     strSql.Append("where WarehouseCode=@WarehouseCode and ");
     strSql.Append("FishId=@FishId");
     MySqlParameter[] parameter =
     {
         new MySqlParameter("@CONTANERNO",     list.CNOTANERNO),
         new MySqlParameter("@QUANTITYOFBAGS", list.QUANTITYOFBAGS),
         new MySqlParameter("@GROSSWEIGHT",    list.GROSSWEIGHT),
         new MySqlParameter("@NETWEIGHT",      list.NETWEIGHT),
         new MySqlParameter("@modifyman",      list.Modifyman),
         new MySqlParameter("@modifytime",     list.Modifytime),
         new MySqlParameter("@createman",      list.Createman),
         new MySqlParameter("@createtime",     list.Createtime),
         new MySqlParameter("@WarehouseCode",  list.WarehouseCode),
         new MySqlParameter("@FishId",         list.FishId)
     };
     SQLString.Add(strSql, parameter);
 }
Ejemplo n.º 2
0
        public override void Save()
        {
            dataGridView1.EndEdit();
            List <FishEntity.PackingWeightListEntity> ModelList = new List <FishEntity.PackingWeightListEntity>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                _List = new FishEntity.PackingWeightListEntity();
                _List.WarehouseCode  = num1; //row.Cells["WarehouseCode"].Value == null ? string.Empty : row.Cells["WarehouseCode"].Value.ToString();
                _List.FishId         = num2; //row.Cells["FishId"].Value == null ? string.Empty : row.Cells["FishId"].Value.ToString();
                _List.CNOTANERNO     = row.Cells["CONTANERNO"].Value == null ? string.Empty : row.Cells["CONTANERNO"].Value.ToString();
                _List.QUANTITYOFBAGS = row.Cells["QUANTITYOFBAGS"].Value == null ? string.Empty : row.Cells["QUANTITYOFBAGS"].Value.ToString();
                _List.GROSSWEIGHT    = row.Cells["GROSSWEIGHT"].Value == null ? string.Empty : row.Cells["GROSSWEIGHT"].Value.ToString();
                _List.NETWEIGHT      = row.Cells["NETWEIGHT"].Value == null ? string.Empty : row.Cells["NETWEIGHT"].Value.ToString();
                //_List.Createman=_List.Modifyman = FishEntity.Variable.User.username;
                //_List.Createtime = _List.Createtime =DateTime.Now;
                ModelList.Add(_List);
            }
            if (ModelList == null)
            {
                return;
            }
            bool result = _bll.add(ModelList);

            if (result == true)
            {
                MessageBox.Show("保存成功");

                dataGridView1.AllowUserToAddRows    = false;
                dataGridView1.AllowUserToDeleteRows = false;
                dataGridView1.ReadOnly = true;

                tmiAdd.Visible      = true;
                tmiQuery.Visible    = true;
                tmiModify.Visible   = false;
                tmiDelete.Visible   = false;
                tmiReview.Visible   = false;
                tmiSave.Visible     = false;
                tmiCancel.Visible   = false;
                tmiExport.Visible   = false;
                tmiNext.Visible     = false;
                tmiPrevious.Visible = false;
                tmiClose.Visible    = true;
            }
            else
            {
                MessageBox.Show("保存失败,请重试");
            }

            base.Save();
        }
Ejemplo n.º 3
0
        public bool add(List <FishEntity.PackingWeightListEntity> modelList)
        {
            Hashtable     SQLString = new Hashtable();
            StringBuilder strSql    = new StringBuilder();

            foreach (FishEntity.PackingWeightListEntity list in modelList)
            {
                list.Createtime = list.Modifytime = dt();
                list.Createman  = list.Modifyman = FishEntity.Variable.User.username;

                if (Exists(list.WarehouseCode, list.FishId) == true)
                {
                    edit(list, SQLString, strSql);
                }
                else
                {
                    insert(list, SQLString, strSql);
                }
            }

            DataTable tab = table();

            if (tab != null && tab.Rows.Count > 0)
            {
                FishEntity.PackingWeightListEntity list = new FishEntity.PackingWeightListEntity();
                string person = string.Empty, proId = string.Empty;
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    person = tab.Rows[i]["WarehouseCode"].ToString();
                    proId  = tab.Rows[i]["FishId"].ToString();
                    list   = modelList.Find((k) =>
                    {
                        return(k.WarehouseCode.Equals(person) && k.FishId.Equals(proId));
                    });

                    if (list == null)
                    {
                        del(person, proId, SQLString, strSql);
                    }
                }
            }

            return(MySqlHelper.ExecuteSqlTran(SQLString));
        }
Ejemplo n.º 4
0
 void insert(FishEntity.PackingWeightListEntity list, Hashtable SQLString, StringBuilder strSql)
 {
     strSql = new StringBuilder();
     strSql.Append("insert into t_PackingWeightList (");
     strSql.Append("WarehouseCode,FishId,CONTANERNO,QUANTITYOFBAGS,GROSSWEIGHT,NETWEIGHT,modifytime,modifyman,createman,createtime)");
     strSql.Append("values (");
     strSql.Append("@WarehouseCode,@FishId,@CONTANERNO,@QUANTITYOFBAGS,@GROSSWEIGHT,@NETWEIGHT,@modifytime,@modifyman,@createman,@createtime)");
     MySqlParameter[] parameter =
     {
         new MySqlParameter("@WarehouseCode",  list.WarehouseCode),
         new MySqlParameter("@FishId",         list.FishId),
         new MySqlParameter("@CONTANERNO",     list.CNOTANERNO),
         new MySqlParameter("@QUANTITYOFBAGS", list.QUANTITYOFBAGS),
         new MySqlParameter("@GROSSWEIGHT",    list.GROSSWEIGHT),
         new MySqlParameter("@NETWEIGHT",      list.NETWEIGHT),
         new MySqlParameter("@modifyman",      list.Modifyman),
         new MySqlParameter("@modifytime",     list.Modifytime),
         new MySqlParameter("@createman",      list.Createman),
         new MySqlParameter("@createtime",     list.Createtime)
     };
     SQLString.Add(strSql, parameter);
 }
Ejemplo n.º 5
0
        public FishEntity.PackingWeightListEntity getModel(DataRow row)
        {
            FishEntity.PackingWeightListEntity model = new FishEntity.PackingWeightListEntity();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.Id = int.Parse(row["id"].ToString());
                }
                if (row["WarehouseCode"] != null)
                {
                    model.WarehouseCode = row["WarehouseCode"].ToString();
                }
                if (row["FishId"] != null)
                {
                    model.FishId = row["FishId"].ToString();
                }
                if (row["QUANTITYOFBAGS"] != null)
                {
                    model.QUANTITYOFBAGS = row["QUANTITYOFBAGS"].ToString();
                }
                if (row["GROSSWEIGHT"] != null)
                {
                    model.GROSSWEIGHT = row["GROSSWEIGHT"].ToString();
                }
                if (row["CONTANERNO"] != null)
                {
                    model.CNOTANERNO = row["CONTANERNO"].ToString();
                }
                if (row["NETWEIGHT"] != null)
                {
                    model.NETWEIGHT = row["NETWEIGHT"].ToString();
                }
            }

            return(model);
        }