Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="WTPID">    </param>
        /// <returns></returns>
        public static List <Entity.ProductDetail> GetProductDetailEx(int WTPID)
        {
            List <Entity.ProductDetail> list = new List <Entity.ProductDetail>();
            DBOperatorBase        db         = new DataBase();
            IDBTypeElementFactory dbFactory  = db.GetDBTypeElementFactory();

            try
            {
                IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [vProductDetail] where WTPID='" + WTPID + "'", null);
                while (dataReader.Read())
                {
                    Entity.ProductDetail entity = new Entity.ProductDetail();
                    entity.DetailID = DataHelper.ParseToInt(dataReader["DetailID"].ToString());
                    entity.WTPID    = DataHelper.ParseToInt(dataReader["WTPID"].ToString());
                    entity.ItemCode = dataReader["ItemCode"].ToString();
                    entity.PondID   = DataHelper.ParseToInt(dataReader["PondID"].ToString());
                    entity.Name     = dataReader["Name"].ToString();
                    entity.Status   = DataHelper.ParseToInt(dataReader["Status"].ToString());
                    entity.Amount   = decimal.Parse(dataReader["Amount"].ToString());
                    list.Add(entity);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.Conn.Close();
            }
            return(list);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DateTime">    </param>
        /// <returns></returns>
        public static List <Entity.ProductDetail> GetSumProductDetail()
        {
            List <Entity.ProductDetail> list = new List <Entity.ProductDetail>();
            DBOperatorBase        db         = new DataBase();
            IDBTypeElementFactory dbFactory  = db.GetDBTypeElementFactory();

            try
            {
                string      Start      = string.Format("{0}-01-01", DateTime.Now.Year);
                string      End        = string.Format("{0}-12-31", DateTime.Now.Year);
                IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "select sum(Amount) as Total,WasteName from vProductDetail where Status=2 and DateTime>='" + Start + "' and DateTime<='" + End + "' group by WasteName", null);
                while (dataReader.Read())
                {
                    Entity.ProductDetail entity = new Entity.ProductDetail();
                    entity.Name   = dataReader["WasteName"].ToString();
                    entity.Amount = decimal.Parse(dataReader["Total"].ToString());
                    list.Add(entity);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.Conn.Close();
            }
            return(list);
        }
Example #3
0
        public static int UpdateProductDetail(Entity.ProductDetail entity)
        {
            int                   iReturn   = 0;
            DBOperatorBase        db        = new DataBase();
            IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory();
            SqlTransactionHelper  thelper   = new SqlTransactionHelper(DAL.Config.con);
            IDbTransaction        trans     = thelper.StartTransaction();

            try
            {
                IDbDataParameter[] prams =
                {
                    dbFactory.MakeInParam("@DetailID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DetailID.GetType().ToString()), entity.DetailID, 32),
                    dbFactory.MakeInParam("@ItemCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ItemCode.GetType().ToString()), entity.ItemCode, 20),
                    dbFactory.MakeInParam("@PondID",   DBTypeConverter.ConvertCsTypeToOriginDBType(entity.PondID.GetType().ToString()),   entity.PondID,   32),
                    dbFactory.MakeInParam("@Status",   DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Status.GetType().ToString()),   entity.Status,   32),
                    dbFactory.MakeInParam("@Amount",   DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Amount.GetType().ToString()),   entity.Amount, 10)
                };
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_ProductDetail_Update", prams);
                thelper.CommitTransaction(trans);
                iReturn = 1;
            }
            catch (Exception ex)
            {
                thelper.RollTransaction(trans);
                iReturn = 0;
            }
            finally
            {
                db.Conn.Close();
            }
            return(iReturn);
        }
Example #4
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string msg = checkInput();

            if (msg != "")
            {
                Alert.Show(msg);
                return;
            }
            else
            {
                int iReturn = 0;
                try
                {
                    Entity.WasteToProduct entity = new Entity.WasteToProduct();
                    entity.CreateDate = DateTime.Now;
                    entity.UpdateDate = DateTime.Now;
                    entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                    entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                    entity.DateTime   = FDate.SelectedDate;
                    entity.FromPondID = int.Parse(drop_Pond.SelectedValue);
                    entity.FromAmount = decimal.Parse(NB_Amount.Text);

                    entity.FromWasteCode = DAL.Pond.GetPond(int.Parse(drop_Pond.SelectedValue)).Stores;
                    entity.HanderManID   = int.Parse(hf_HandelManID.Text);
                    if (!string.IsNullOrEmpty(txt_Receiver.Text.Trim()))
                    {
                        entity.ReceiverID = int.Parse(hf_ReceiverID.Text);
                    }
                    else
                    {
                        entity.ReceiverID = 0;
                    }

                    entity.Status = 1;

                    if (string.IsNullOrEmpty(sGuid))
                    {
                        //Add
                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.ProductDetail>         Adds         = new List <Entity.ProductDetail>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.ProductDetail add = new Entity.ProductDetail();
                            add.Name     = newAddedList[i]["Name"].ToString();
                            add.PondID   = DAL.Pond.GetPondByName(add.Name).PondID;
                            add.Amount   = decimal.Parse(newAddedList[i]["Amount"].ToString());
                            add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList[i]["WasteName"].ToString());
                            Adds.Add(add);
                        }

                        //List<Dictionary<string, object>> newAddedList2 = Grid2.GetNewAddedList();
                        //List<Entity.FinalWaste> Adds2 = new List<Entity.FinalWaste>();
                        //for (int i = 0; i < newAddedList2.Count; i++)
                        //{
                        //    Entity.FinalWaste add = new Entity.FinalWaste();
                        //    add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString());
                        //    add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString());
                        //    Adds2.Add(add);
                        //}

                        iReturn = DAL.WasteToProduct.AddWasteToProductEntity(entity, Adds);
                    }
                    else
                    {
                        //Update
                        entity.DealID = int.Parse(sGuid);
                        List <int> deletedRows = Grid1.GetDeletedList();
                        List <Entity.ProductDetail> Deletes = new List <Entity.ProductDetail>();
                        foreach (int rowIndex in deletedRows)
                        {
                            Entity.ProductDetail delete = new Entity.ProductDetail();
                            delete.DetailID = Convert.ToInt32(Grid1.DataKeys[rowIndex][1]);
                            Deletes.Add(delete);
                        }


                        Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                        List <Entity.ProductDetail> Updates = new List <Entity.ProductDetail>();
                        foreach (int rowIndex in modifiedDict.Keys)
                        {
                            Entity.ProductDetail update = new Entity.ProductDetail();
                            update.DetailID = Convert.ToInt32(Grid1.DataKeys[rowIndex][1]);
                            update.ItemCode = DAL.Waste.GetWasteCodeByName(Grid1.DataKeys[rowIndex][2].ToString());
                            update.Amount   = decimal.Parse(Grid1.DataKeys[rowIndex][3].ToString());
                            update.PondID   = 1;
                            update.Status   = 1;
                            Updates.Add(update);
                        }

                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.ProductDetail>         Adds         = new List <Entity.ProductDetail>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.ProductDetail add = new Entity.ProductDetail();
                            add.Name     = newAddedList[i]["Name"].ToString();
                            add.PondID   = DAL.Pond.GetPondByName(add.Name).PondID;
                            add.Amount   = decimal.Parse(newAddedList[i]["Amount"].ToString());
                            add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList[i]["WasteName"].ToString());
                            Adds.Add(add);
                        }


                        //List<int> deletedRows2 = Grid2.GetDeletedList();
                        //List<Entity.FinalWaste> Deletes2 = new List<Entity.FinalWaste>();
                        //foreach (int rowIndex in deletedRows2)
                        //{
                        //    Entity.FinalWaste delete = new Entity.FinalWaste();
                        //    delete.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]);
                        //    Deletes2.Add(delete);
                        //}


                        //Dictionary<int, Dictionary<string, object>> modifiedDict2 = Grid2.GetModifiedDict();
                        //List<Entity.FinalWaste> Updates2 = new List<Entity.FinalWaste>();
                        //foreach (int rowIndex in modifiedDict2.Keys)
                        //{
                        //    Entity.FinalWaste update = new Entity.FinalWaste();
                        //    update.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]);
                        //    update.ItemCode = DAL.Waste.GetWasteCodeByName(Grid2.DataKeys[rowIndex][2].ToString());
                        //    update.Result = decimal.Parse(Grid2.DataKeys[rowIndex][3].ToString());
                        //    update.Status = 1;
                        //    Updates2.Add(update);
                        //}

                        //List<Dictionary<string, object>> newAddedList2 = Grid2.GetNewAddedList();
                        //List<Entity.FinalWaste> Adds2 = new List<Entity.FinalWaste>();
                        //for (int i = 0; i < newAddedList2.Count; i++)
                        //{
                        //    Entity.FinalWaste add = new Entity.FinalWaste();
                        //    add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString());
                        //    add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString());
                        //    Adds2.Add(add);
                        //}
                        iReturn = DAL.WasteToProduct.UpdateWasteToProductEntity(entity, Adds, Updates, Deletes);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
                if (iReturn == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    //            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning);
                }
            }
            #endregion
        }