예제 #1
0
 public int Editkucunlog(B2b_com_pro_kucunlog m)
 {
     using (var helper = new SqlHelper())
     {
         int r = new Internalb2b_com_pro_kucunlog(helper).Editkucunlog(m);
         return(r);
     }
 }
예제 #2
0
        internal int Editkucunlog(B2b_com_pro_kucunlog m)
        {
            if (m.id > 0)
            {
                string sql = @"UPDATE  [b2b_com_pro_kucunlog]
                               SET [orderid] = @orderid 
                                  ,[proid] = @proid 
                                  ,[servertype] = @servertype 
                                  ,[daydate] = @daydate 
                                  ,[proSpeciId] = @proSpeciId 
                                  ,[surplusnum] = @surplusnum 
                                  ,[opertype] = @opertype 
                                  ,[operor] = @operor 
                                  ,[opertime] = @opertime 
                                  ,oper=@oper
                             WHERE id=@id";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@id", m.id);
                cmd.AddParam("@orderid", m.orderid);
                cmd.AddParam("@proid", m.proid);
                cmd.AddParam("@servertype", m.servertype);
                cmd.AddParam("@daydate", m.daydate);
                cmd.AddParam("@proSpeciId", m.proSpeciId);
                cmd.AddParam("@surplusnum", m.surplusnum);
                cmd.AddParam("@opertype", m.opertype);
                cmd.AddParam("@operor", m.operor);
                cmd.AddParam("@opertime", m.opertime);
                cmd.AddParam("@oper", m.oper);
                cmd.ExecuteNonQuery();
                return(m.id);
            }
            else
            {
                string sql = @"INSERT [b2b_com_pro_kucunlog]
                                   ([orderid]
                                   ,[proid]
                                   ,[servertype]
                                   ,[daydate]
                                   ,[proSpeciId]
                                   ,[surplusnum]
                                   ,[opertype]
                                   ,[operor]
                                   ,[opertime]
                                   ,oper)
                             VALUES
                                   (@orderid 
                                   ,@proid 
                                   ,@servertype 
                                   ,@daydate 
                                   ,@proSpeciId 
                                   ,@surplusnum 
                                   ,@opertype 
                                   ,@operor 
                                   ,@opertime
                                   ,@oper);select @@identity;";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@orderid", m.orderid);
                cmd.AddParam("@proid", m.proid);
                cmd.AddParam("@servertype", m.servertype);
                cmd.AddParam("@daydate", m.daydate);
                cmd.AddParam("@proSpeciId", m.proSpeciId);
                cmd.AddParam("@surplusnum", m.surplusnum);
                cmd.AddParam("@opertype", m.opertype);
                cmd.AddParam("@operor", m.operor);
                cmd.AddParam("@opertime", m.opertime);
                cmd.AddParam("@oper", m.oper);

                object o = cmd.ExecuteScalar();
                return(int.Parse(o.ToString()));
            }
        }
예제 #3
0
        internal int EditB2b_com_pro_Speci(B2b_com_pro_Speci m)
        {
            string sql = "select  id  from b2b_com_pro_Speci where proid=" + m.proid + " and speci_type_nameid_Array='" + m.speci_type_nameid_Array + "'";
            var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
            var    id  = 0;

            using (var reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    id = reader.GetValue <int>("id");
                }
            }


            #region 编辑
            if (id > 0)
            {
                string sql1 = "update b2b_com_pro_Speci set speci_name='" + m.speci_name + "',speci_face_price='" + m.speci_face_price + "',speci_advise_price='" + m.speci_advise_price + "',speci_agent1_price='" + m.speci_agent1_price + "',speci_agent2_price='" + m.speci_agent2_price + "',speci_agent3_price='" + m.speci_agent3_price + "',speci_agentsettle_price='" + m.speci_agentsettle_price + "',speci_pro_weight='" + m.speci_pro_weight + "',speci_totalnum='" + m.speci_totalnum + "',speci_type_nameid_Array='" + m.speci_type_nameid_Array + "' where id=" + id;
                var    cmd1 = sqlHelper.PrepareTextSqlCommand(sql1);
                cmd1.ExecuteNonQuery();


                #region  步修改导入产品规格的成本价:获得导入产品id 和 导入产品规格的成本价
                IList <B2b_com_pro> drprolist = new List <B2b_com_pro>();//导入产品列表
                string s1 = "select id,com_id from b2b_com_pro where bindingid=" + m.proid;
                var    c1 = sqlHelper.PrepareTextSqlCommand(s1);
                using (var reader = c1.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        drprolist.Add(new B2b_com_pro
                        {
                            Id     = reader.GetValue <int>("id"),
                            Com_id = reader.GetValue <int>("com_id")
                        });
                    }
                }
                if (drprolist != null)
                {
                    if (drprolist.Count > 0)
                    {
                        foreach (B2b_com_pro drpro in drprolist)
                        {
                            if (drpro != null)
                            {
                                #region 获得导入产品成本价
                                int drbinding_Agentid      = 0; //导入产品公司的绑定分销
                                int drbinding_Warrant_type = 0; //导入产品公司的绑定分销的分销类型(验证扣款;出票扣款)
                                int drbinding_Agentlevel   = 3; //导入产品公司的绑定分销 在原始公司下的分销级别

                                var comdata = B2bCompanyData.GetCompany(drpro.Com_id);
                                if (comdata != null)
                                {
                                    drbinding_Agentid = comdata.Bindingagent;
                                }

                                var agentmodel = AgentCompanyData.GetAgentWarrant(drbinding_Agentid, m.comid);
                                if (agentmodel != null)
                                {
                                    drbinding_Agentlevel   = agentmodel.Warrant_level;
                                    drbinding_Warrant_type = agentmodel.Warrant_type;
                                }

                                decimal aprice = 0;
                                if (drbinding_Agentlevel == 1)
                                {
                                    aprice = m.speci_agent1_price;
                                }
                                else if (drbinding_Agentlevel == 2)
                                {
                                    aprice = m.speci_agent2_price;
                                }
                                else if (drbinding_Agentlevel == 3)
                                {
                                    aprice = m.speci_agent3_price;
                                }
                                //修改绑定规格的成本价格
                                string s2 = "update b2b_com_pro_Speci set speci_agentsettle_price='" + aprice + "' where proid=" + drpro.Id + " and binding_id=" + id;
                                var    c2 = sqlHelper.PrepareTextSqlCommand(s2);
                                c2.ExecuteNonQuery();
                                #endregion
                            }
                        }
                    }
                }
                #endregion


                #region 库存变化日志
                try
                {
                    B2b_com_pro_kucunlog kucunlog = new B2b_com_pro_kucunlog
                    {
                        id         = 0,
                        orderid    = 0,
                        proid      = m.proid,
                        servertype = new B2bComProData().GetServertypeByProid(m.proid),
                        daydate    = DateTime.Parse("1970-01-01"),
                        proSpeciId = id,
                        surplusnum = m.speci_totalnum,
                        operor     = "",
                        opertime   = DateTime.Now,
                        opertype   = "编辑规格",
                        oper       = "多规格"
                    };
                    new B2b_com_pro_kucunlogData().Editkucunlog(kucunlog);
                }
                catch { }
                #endregion


                return(id);
            }
            #endregion
            #region 添加
            else
            {
                string sql2       = "INSERT INTO  [b2b_com_pro_Speci] (speci_name,speci_face_price,speci_advise_price,speci_agent1_price,speci_agent2_price,speci_agent3_price,speci_agentsettle_price,speci_pro_weight,speci_totalnum,comid,proid,speci_type_nameid_Array)  VALUES  ('" + m.speci_name + "','" + m.speci_face_price + "','" + m.speci_advise_price + "','" + m.speci_agent1_price + "','" + m.speci_agent2_price + "','" + m.speci_agent3_price + "','" + m.speci_agentsettle_price + "','" + m.speci_pro_weight + "','" + m.speci_totalnum + "','" + m.comid + "','" + m.proid + "','" + m.speci_type_nameid_Array + "');select @@identity;";
                var    cmd2       = sqlHelper.PrepareTextSqlCommand(sql2);
                object o          = cmd2.ExecuteScalar();
                int    newspeciid = int.Parse(o.ToString());

                #region  步修改导入产品规格的成本价:获得导入产品id 和 导入产品规格的成本价
                IList <B2b_com_pro> drprolist = new List <B2b_com_pro>();//导入产品列表
                string s1 = "select id,com_id from b2b_com_pro where bindingid=" + m.proid;
                var    c1 = sqlHelper.PrepareTextSqlCommand(s1);
                using (var reader = c1.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        drprolist.Add(new B2b_com_pro
                        {
                            Id     = reader.GetValue <int>("id"),
                            Com_id = reader.GetValue <int>("com_id")
                        });
                    }
                }
                if (drprolist != null)
                {
                    if (drprolist.Count > 0)
                    {
                        foreach (B2b_com_pro drpro in drprolist)
                        {
                            if (drpro != null)
                            {
                                #region 获得导入产品成本价
                                int drbinding_Agentid      = 0; //导入产品公司的绑定分销
                                int drbinding_Warrant_type = 0; //导入产品公司的绑定分销的分销类型(验证扣款;出票扣款)
                                int drbinding_Agentlevel   = 3; //导入产品公司的绑定分销 在原始公司下的分销级别

                                var comdata = B2bCompanyData.GetCompany(drpro.Com_id);
                                if (comdata != null)
                                {
                                    drbinding_Agentid = comdata.Bindingagent;
                                }

                                var agentmodel = AgentCompanyData.GetAgentWarrant(drbinding_Agentid, m.comid);
                                if (agentmodel != null)
                                {
                                    drbinding_Agentlevel   = agentmodel.Warrant_level;
                                    drbinding_Warrant_type = agentmodel.Warrant_type;
                                }

                                decimal aprice = 0;
                                if (drbinding_Agentlevel == 1)
                                {
                                    aprice = m.speci_agent1_price;
                                }
                                else if (drbinding_Agentlevel == 2)
                                {
                                    aprice = m.speci_agent2_price;
                                }
                                else if (drbinding_Agentlevel == 3)
                                {
                                    aprice = m.speci_agent3_price;
                                }
                                //修改绑定规格的成本价格
                                string sqlTxt = @"insert into b2b_com_pro_Speci (comid,speci_name,speci_face_price,speci_advise_price,speci_agentsettle_price,speci_pro_weight,speci_totalnum,proid,speci_type_nameid_array,binding_id)
select " + drpro.Com_id + ",speci_name,speci_face_price,speci_advise_price," + aprice + ",speci_pro_weight,speci_totalnum," + drpro.Id + ",speci_type_nameid_array,id  from b2b_com_pro_Speci where id=" + newspeciid + "";
                                var    c2     = sqlHelper.PrepareTextSqlCommand(sqlTxt);
                                c2.ExecuteNonQuery();

                                #endregion
                            }
                        }
                    }
                }
                #endregion

                #region 库存变化日志
                try
                {
                    B2b_com_pro_kucunlog kucunlog = new B2b_com_pro_kucunlog
                    {
                        id         = 0,
                        orderid    = 0,
                        proid      = m.proid,
                        servertype = new B2bComProData().GetServertypeByProid(m.proid),
                        daydate    = DateTime.Parse("1970-01-01"),
                        proSpeciId = newspeciid,
                        surplusnum = m.speci_totalnum,
                        operor     = "",
                        opertime   = DateTime.Now,
                        opertype   = "新加规格",
                        oper       = "多规格"
                    };
                    new B2b_com_pro_kucunlogData().Editkucunlog(kucunlog);
                }
                catch { }
                #endregion

                return(newspeciid);
            }
            #endregion
        }