Example #1
0
        public bool Load(int OrderId, int GoodsId)
        {
            string  sql = string.Format("select * from OrderDetail where OrderId={0} and GoodsId={1}", OrderId, GoodsId);
            DataSet ds  = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                Id             = DBTool.GetIntFromRow(row, "Id", 0);
                OrderId        = DBTool.GetIntFromRow(row, "OrderId", 0);
                GoodsId        = DBTool.GetIntFromRow(row, "GoodsId", 0);
                Model          = DBTool.GetStringFromRow(row, "Model", "");
                Num            = DBTool.GetIntFromRow(row, "Num", 0);
                Discount       = DBTool.GetDoubleFromRow(row, "Discount", 0);
                SalePrice      = DBTool.GetDoubleFromRow(row, "SalePrice", 0);
                Price          = DBTool.GetDoubleFromRow(row, "Price", 0);
                IsGift         = DBTool.GetIntFromRow(row, "IsGift", 0);
                InPrice        = DBTool.GetDoubleFromRow(row, "InPrice", 0);
                TaxInPrice     = DBTool.GetDoubleFromRow(row, "TaxInPrice", 0);
                AC             = DBTool.GetDoubleFromRow(row, "AC", 0);
                Point          = DBTool.GetDoubleFromRow(row, "Point", 0);
                Amount         = DBTool.GetDoubleFromRow(row, "Amount", 0);
                IsLack         = DBTool.GetIntFromRow(row, "IsLack", 0);
                PurchaseStatus = DBTool.GetStringFromRow(row, "PurchaseStatus", "");
                PurchaseMemo   = DBTool.GetStringFromRow(row, "PurchaseMemo", "");
                PickNum        = DBTool.GetIntFromRow(row, "PickNum", 0);
                OldGoodsId     = DBTool.GetIntFromRow(row, "OldGoodsId", 0);
                SkuName        = DBTool.GetStringFromRow(row, "SkuName", "");
                GroupParentId  = DBTool.GetIntFromRow(row, "GroupParentId", 0);
                IsShow         = DBTool.GetIntFromRow(row, "IsShow", 0);
                IsCalc         = DBTool.GetIntFromRow(row, "IsCalc", 0);
                TaxAC          = DBTool.GetDoubleFromRow(row, "TaxAC", 0);
                return(true);
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// 根据用户的token直接登录
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public UserInfo LoginByToken(string token)
        {
            UserInfo info = new UserInfo();
            string   sql  = string.Format(" select * from view_sysusers where token='{0}' and IsValid = 1 ", token);
            DataSet  ds   = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count == 1)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (DBTool.GetDateTimeFromRow(row, "tokenEndDate") > DateTime.Now)
                {
                    LoadUserInfoFromRow(info, row);
                    return(info);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        public bool Load()
        {
            string  sql = string.Format("select * from GoodsPackageLog where id={0}", Id);
            DataSet ds  = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                Id         = DBTool.GetIntFromRow(row, "Id", 0);
                GoodsId    = DBTool.GetIntFromRow(row, "GoodsId", 0);
                Type       = DBTool.GetStringFromRow(row, "Type", "");
                OldNum     = DBTool.GetIntFromRow(row, "OldNum", 0);
                Num        = DBTool.GetIntFromRow(row, "Num", 0);
                OldName    = DBTool.GetStringFromRow(row, "OldName", "");
                Name       = DBTool.GetStringFromRow(row, "Name", "");
                IsDefault  = DBTool.GetIntFromRow(row, "IsDefault", 0);
                OldBarCode = DBTool.GetStringFromRow(row, "OldBarCode", "");
                BarCode    = DBTool.GetStringFromRow(row, "BarCode", "");
                UserId     = DBTool.GetIntFromRow(row, "UserId", 0);
                UpdateTime = DBTool.GetDateTimeFromRow(row, "UpdateTime");
                return(true);
            }
            return(false);
        }
Example #4
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public UserInfo IsLogin(string loginName, string passWord)
        {
            UserInfo info = new UserInfo();
            string   sql  = string.Format(" select * from view_sysusers where loginName='{0}' and IsValid = 1 ", loginName);
            DataSet  ds   = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count == 1)
            {
                if (MD5.GetMD5(passWord) == DBTool.GetStringFromRow(ds.Tables[0].Rows[0], "PassWord", ""))
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    LoadUserInfoFromRow(info, row);
                    this.Id = info.Id;
                    this.Load();
                    if (this.tokenEndDate < DateTime.Now)
                    {
                        this.token        = Guid.NewGuid().ToString() + Guid.NewGuid().ToString();
                        this.tokenEndDate = DateTime.Now.AddMonths(1);
                        if (this.Save() > 0)
                        {
                            info.token        = this.token;
                            info.tokenEndDate = this.tokenEndDate;
                        }
                    }
                    return(info);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        /// <summary>
        /// 根据名称Load  addBy_WangPengliang
        /// </summary>
        /// <returns></returns>
        public bool LoadByName(string name)
        {
            string  sql = string.Format("select * from Company where name='{0}'", name);
            DataSet ds  = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                m_Id             = DBTool.GetIntFromRow(row, "Id", 0);
                m_name           = DBTool.GetStringFromRow(row, "name", "");
                m_ShortName      = DBTool.GetStringFromRow(row, "ShortName", "");
                m_HasSub         = DBTool.GetIntFromRow(row, "HasSub", 0);
                m_ComPath        = DBTool.GetStringFromRow(row, "ComPath", "");
                m_ParentId       = DBTool.GetIntFromRow(row, "ParentId", 0);
                m_TypeId         = DBTool.GetIntFromRow(row, "TypeId", 0);
                m_Status         = DBTool.GetStringFromRow(row, "Status", "");
                m_EmployeesNum   = DBTool.GetStringFromRow(row, "EmployeesNum", "");
                m_Province       = DBTool.GetStringFromRow(row, "Province", "");
                m_City           = DBTool.GetStringFromRow(row, "City", "");
                m_Area           = DBTool.GetStringFromRow(row, "Area", "");
                m_Street         = DBTool.GetStringFromRow(row, "Street", "");
                m_Mansion        = DBTool.GetStringFromRow(row, "Mansion", "");
                m_Room           = DBTool.GetStringFromRow(row, "Room", "");
                m_Address        = DBTool.GetStringFromRow(row, "Address", "");
                m_PostCode       = DBTool.GetStringFromRow(row, "PostCode", "");
                m_AddTime        = DBTool.GetDateTimeFromRow(row, "AddTime");
                m_UpdateTime     = DBTool.GetDateTimeFromRow(row, "UpdateTime");
                m_InnerUserId    = DBTool.GetIntFromRow(row, "InnerUserId", 0);
                m_Telphone       = DBTool.GetStringFromRow(row, "Telphone", "");
                m_Fax            = DBTool.GetStringFromRow(row, "Fax", "");
                m_WebSite        = DBTool.GetStringFromRow(row, "WebSite", "");
                m_RegisterMethod = DBTool.GetStringFromRow(row, "RegisterMethod", "");
                return(true);
            }
            return(false);
        }
Example #6
0
        /// <summary>
        /// ERP FOrderReceiveMoney.cs 中调用
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            string  sql = string.Format("select * from OrderStatement where id={0}", m_Id);
            DataSet ds  = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                m_Id            = DBTool.GetIntFromRow(row, "Id", 0);
                m_BranchId      = DBTool.GetIntFromRow(row, "BranchId", 0);
                m_ComId         = DBTool.GetIntFromRow(row, "ComId", 0);
                m_Memo          = DBTool.GetStringFromRow(row, "Memo", "");
                m_SumMoney      = DBTool.GetDoubleFromRow(row, "SumMoney", 0);
                m_PaidMoney     = DBTool.GetDoubleFromRow(row, "PaidMoney", 0);
                m_PayStatus     = DBTool.GetStringFromRow(row, "PayStatus", "");
                m_UserId        = DBTool.GetIntFromRow(row, "UserId", 0);
                m_PrintNum      = DBTool.GetIntFromRow(row, "PrintNum", 0);
                m_UpdateTime    = DBTool.GetDateTimeFromRow(row, "UpdateTime");
                m_NeedToInvoice = DBTool.GetDoubleFromRow(row, "NeedToInvoice", 0);
                m_InvoiceMoney  = DBTool.GetDoubleFromRow(row, "InvoiceMoney", 0);
                return(true);
            }
            return(false);
        }
Example #7
0
        /// <summary>
        /// 调拨入库,撤销入库
        /// </summary>
        /// <param name="TransferId"></param>
        /// <param name="storeId"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public bool InBoundT(int TransferId, int storeId, int UserId)
        {
            Transfer t = new Transfer();

            t.Id = TransferId;
            t.Load();
            bool storevalid = false;

            if (t.InStoreId == storeId)
            {
                t.InStoreDate   = DateTime.Now;
                t.Status        = CommenClass.TransferStatus.调拨入库.ToString();
                t.InStoreUserId = UserId;
                t.Save();
                storevalid = true;
            }
            else if (t.OutStoreId == storeId)
            {
                t.UpdateDate   = DateTime.Now;
                t.Status       = CommenClass.TransferStatus.待出库.ToString();
                t.OutStoreDate = new DateTime(1900, 1, 1);
                t.Save();
                storevalid = true;
            }
            else
            {
                return(false);
            }
            if (storevalid)
            {
                DataSet ds = ReadTransferDetail(TransferId);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int        goodsId = DBTool.GetIntFromRow(row, "GoodsId", 0);
                    int        num     = DBTool.GetIntFromRow(row, "Num", 0);
                    int        Id      = DBTool.GetIntFromRow(row, "Id", 0);
                    double     AC      = DBTool.GetDoubleFromRow(row, "AC", 0);
                    GoodsStore gs      = new GoodsStore();
                    gs.GoodsId = goodsId;
                    gs.StoreId = storeId;
                    gs.Load(storeId, goodsId);
                    //修改库存 成本和数量,如果是固定成本的 直接赋值
                    GoodsAC ga = new GoodsAC();
                    if (ga.Load(t.InBranchId, goodsId))
                    {
                        gs.AC = ga.Goods_AC;
                    }
                    else
                    {
                        if ((gs.Num + num) != 0)
                        {
                            gs.AC = (gs.AC * gs.Num + num * AC) / (gs.Num + num);
                        }
                        else
                        {
                            gs.AC = AC;
                        }
                    }
                    gs.Num        = gs.Num + num;
                    gs.UpdateTime = DateTime.Now;
                    gs.Save();
                    GoodsStoreDetail gsd = new GoodsStoreDetail();
                    gsd.GoodsId    = goodsId;
                    gsd.Id         = 0;
                    gsd.NewNum     = gs.Num;
                    gsd.Num        = num;
                    gsd.OldNum     = gs.Num - num;
                    gsd.Operate    = t.Status;
                    gsd.RelationId = TransferId;
                    gsd.StoreId    = storeId;
                    gsd.UpdateTime = DateTime.Now;
                    gsd.UserId     = UserId;
                    gsd.Save();
                }
            }
            return(true);
        }
Example #8
0
        public bool ModifyTransfer(Transfer Tf, Transferdetail[] tfd)
        {
            Transfer Transfer = new Transfer();

            Transfer.Id = Tf.Id;
            Transfer.Load();
            Transfer.InBranchId     = Tf.InBranchId;
            Transfer.InStoreId      = Tf.InStoreId;
            Transfer.InStoreUserId  = Tf.InStoreUserId;
            Transfer.IsInner        = Tf.IsInner;
            Transfer.Memo           = Tf.Memo;
            Transfer.OutStoreId     = Tf.OutStoreId;
            Transfer.OutStoreUserId = Tf.OutStoreUserId;
            Transfer.Status         = Tf.Status;
            Transfer.UpdateDate     = DateTime.Now;
            int TransferId = Transfer.Save();

            if (TransferId > 0)
            {
                DataTable dtOld = this.ReadTransferDetail(TransferId).Tables[0];
                for (int i = 0; i < tfd.Length; i++)
                {
                    DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", tfd[i].GoodsId));
                    if (rows.Length == 1)//有这个商品
                    {
                        int    oldNum  = DBTool.GetIntFromRow(rows[0], "num", 0);
                        string oldMemo = DBTool.GetStringFromRow(rows[0], "Memo", "");
                        if (tfd[i].Num != oldNum || tfd[i].Memo != oldMemo)//有变化需要修改
                        {
                            Transferdetail od = new Transferdetail();
                            od.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                            od.Load();
                            od.Num    = tfd[i].Num;
                            od.Amount = tfd[i].Num * tfd[i].AC;
                            od.Memo   = tfd[i].Memo.Replace(" ", "").Replace("  ", "");
                            od.Save();
                        }
                    }
                    else //新增商品
                    {
                        Transferdetail od = new Transferdetail();
                        od.GoodsId    = tfd[i].GoodsId;
                        od.TransferId = TransferId;
                        od.Model      = tfd[i].Model;
                        od.Unit       = tfd[i].Unit;
                        od.AC         = tfd[i].AC;
                        od.Num        = tfd[i].Num;
                        od.Amount     = tfd[i].Amount;
                        od.Memo       = tfd[i].Memo;
                        od.UpdateDate = DateTime.Now;
                        od.Save();
                    }
                }

                //循环旧表,查找新表中没有的项。删除,记录明细
                foreach (DataRow row in dtOld.Select(""))
                {
                    int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
                    int  oldnum   = DBTool.GetIntFromRow(row, "num", 0);
                    bool isExsist = false;
                    for (int i = 0; i < tfd.Length; i++)
                    {
                        if (tfd[i].GoodsId == goodsId)
                        {
                            isExsist = true;
                            break;
                        }
                    }
                    if (isExsist == false)
                    {
                        //新订单中无 此项
                        int            odId = DBTool.GetIntFromRow(row, "Id", 0);
                        Transferdetail od   = new Transferdetail();
                        od.Id      = odId;
                        od.GoodsId = goodsId;
                        od.Delete();
                    }
                }
            }
            return(true);
        }
Example #9
0
        /// <summary>
        /// 邮件拼接的字符串
        /// </summary>
        /// <param name="applyId"></param>
        /// <param name="memberId"></param>
        /// <returns></returns>
        private static string EmailBodyStr(int applyId, int memberId)
        {
            //申请单明细
            VIPApplyDetail vad      = new VIPApplyDetail();
            List <int>     applyIds = new List <int>();

            applyIds.Add(applyId);
            DataSet       dsDetail = vad.GetApplyDetailByApplyId(applyIds);
            StringBuilder strTable = new StringBuilder();

            //申请单明细  添加英文
            strTable.Append(@"<table style='border-collapse:collapse;'>
<tr style='border:1px solid #aac1de;'>
<td style='border:1px solid #aac1de; padding:5px;'>序号(No.)</td>
<td style='border:1px solid #aac1de; padding:5px;'>商品编号(Id)</td>
<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>商品名称(Product )</td>
<td style='border:1px solid #aac1de; padding:5px;'>单位(Unit)</td>
<td style='border:1px solid #aac1de; padding:5px;'>数量(Num)</td>
<td style='border:1px solid #aac1de; padding:5px;'>单价(Price)</td>
<td style='border:1px solid #aac1de; padding:5px;'>金额(Amount)</td>
</tr>");
            int index = 1;

            foreach (DataRow row in dsDetail.Tables[0].Rows)
            {
                decimal amount = Convert.ToDecimal(row["VIPPrice"]) * Convert.ToInt32(row["Num"]);
                strTable.Append("<tr style='border:1px solid #aac1de;'>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + index.ToString() + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["GoodsId"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px;'>" + row["DisplayName"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["Unit"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["num"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + string.Format("{0:F2}", row["VIPPrice"]) + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + amount.ToString("0.00") + "</td>");
                strTable.Append("</tr>");
                index += 1;
            }
            strTable.Append("</table>");
            string applyId1s = CommenClass.Encrypt.EncryptDES(applyId.ToString(), "leading1");
            //获取token
            Emailapply ea = new Emailapply();

            ea.ApplyId   = applyId;
            ea.MemberId  = memberId;
            ea.Token     = Guid.NewGuid().ToString() + Guid.NewGuid().ToString();
            ea.StartTime = DateTime.Now;
            ea.EndTime   = DateTime.Now.AddDays(30); //DateTime.Now.AddHours(48);
            ea.Save();

            VIPApplyManager vam    = new VIPApplyManager();
            VIPApplyOption  option = new VIPApplyOption();

            option.Id           = applyId;
            option.ConfirmLevel = -1;
            DataRow  row1       = vam.ReadApply(option).Tables[0].Rows[0];
            string   DeptName   = DBTool.GetStringFromRow(row1, "DeptName", "");
            string   RealName   = DBTool.GetStringFromRow(row1, "RealName", "");
            double   SumMoney   = DBTool.GetDoubleFromRow(row1, "SumMoney", 0);
            DateTime UpdateTime = DBTool.GetDateTimeFromRow(row1, "UpdateTime");
            string   ApplyInfo  = string.Format("Id:{0}&nbsp;&nbsp;部门(Dept):{1}&nbsp;&nbsp;申请人(Applicant):{2}&nbsp;&nbsp;总金额(Amount):{3}&nbsp;&nbsp;日期(Date):{4}", applyId, DeptName, RealName, SumMoney, UpdateTime);
            string   url        = CommenClass.SiteUrl.HomeUrl();
            //string url ="http://*****:*****@"
系统邮件,请勿回复!(Don't reply this email.)<br/><br/>
您好,您有1张订单需要审批,明细如下(Hello, There is an application form need you to approve):<br/><br/>
{0}<br/><br/>
{1}<br/><br/> {2}&nbsp;&nbsp;&nbsp;&nbsp;{3}&nbsp;&nbsp;&nbsp;&nbsp;{4}<br/>",
                                       ApplyInfo, strTable, strConfirm, applydetail, strToConfirmOrder);

            return(str);
        }
Example #10
0
        /// <summary>
        /// 修改组合商品明细
        /// </summary>
        /// <param name="InGoodsId"></param>
        /// <param name="Price"></param>
        /// <param name="Ggdetail"></param>
        /// <returns></returns>
        public bool ModifyGoodsGropDetail(int InGoodsId, double Price, GoodsGroupDetail[] Ggdetail)
        {
            Goods goods = new Goods();

            goods.ModifyPrice(InGoodsId, Price);
            if (InGoodsId > 0)
            {
                GoodsGroupDetail ggd   = new GoodsGroupDetail();
                DataTable        dtOld = ggd.GetGoodsGroupDetail(InGoodsId).Tables[0];//读取订单原来的明细
                //循环新表,处理新增商品和 修改过数量和价格的商品
                for (int i = 0; i < Ggdetail.Length; i++)
                {
                    DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", Ggdetail[i].GoodsId));
                    if (rows.Length == 1)//有这个商品
                    {
                        int oldNum = DBTool.GetIntFromRow(rows[0], "num", 0);
                        if (Ggdetail[i].Num != oldNum)//有变化需要修改
                        {
                            GoodsGroupDetail ggdl = new GoodsGroupDetail();
                            ggdl.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                            ggdl.Load();
                            ggdl.Num    = Ggdetail[i].Num;
                            ggdl.UserId = Ggdetail[i].UserId;
                            if (ggdl.Save() > 0)
                            {
                                //记录修改明细记录
                            }
                        }
                    }
                    else //新增商品
                    {
                        GoodsGroupDetail ggdl = new GoodsGroupDetail();
                        ggdl.Id           = 0;
                        ggdl.GoodsGroupId = InGoodsId;
                        ggdl.GoodsId      = Ggdetail[i].GoodsId;
                        ggdl.PackageId    = 0;
                        ggdl.Num          = Ggdetail[i].Num;
                        ggdl.UserId       = Ggdetail[i].UserId;
                        if (ggdl.Save() > 0)
                        {
                            //如果是组合商品,需要新增 组合的明细
                        }
                    }

                    //循环旧表,查找新表中没有的项。删除,记录明细
                    foreach (DataRow row in dtOld.Select())
                    {
                        int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
                        bool isExsist = false;
                        for (int z = 0; z < Ggdetail.Length; i++)
                        {
                            if (Ggdetail[z].GoodsId == goodsId)
                            {
                                isExsist = true;
                                break;
                            }
                        }
                        if (isExsist == false)
                        {
                            //新订单中无 此项
                            int odId = DBTool.GetIntFromRow(row, "Id", 0);
                            GoodsGroupDetail ggdl = new GoodsGroupDetail();
                            ggdl.Id      = odId;
                            ggdl.GoodsId = goodsId;
                            if (ggdl.Delete())//删除订单明细 如果是组合商品 删除
                            {
                                //记录订单 修改记录
                            }
                        }
                    }
                }
            }
            return(true);
        }
Example #11
0
        /// <summary>
        /// 读取符合条件的商品的数量
        /// </summary>
        /// <returns></returns>
        public int ReadGoodsCountInt()
        {
            DataSet ds = ReadGoodsCountDataset();

            return(DBTool.GetIntFromRow(ds.Tables[0].Rows[0], "goodscount", 0));
        }
Example #12
0
        public bool Load(int TPI_OrderId)
        {
            string  sql = string.Format("select * from [Order] where TPI_OrderId={0}", TPI_OrderId);
            DataSet ds  = m_dbo.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                Id              = DBTool.GetIntFromRow(row, "Id", 0);
                ComId           = DBTool.GetIntFromRow(row, "ComId", 0);
                MemberId        = DBTool.GetIntFromRow(row, "MemberId", 0);
                OrderTime       = DBTool.GetDateTimeFromRow(row, "OrderTime");
                PlanDate        = DBTool.GetDateTimeFromRow(row, "PlanDate");
                FinishDate      = DBTool.GetDateTimeFromRow(row, "FinishDate");
                SumMoney        = DBTool.GetDoubleFromRow(row, "SumMoney", 0);
                GrossProfit     = DBTool.GetDoubleFromRow(row, "GrossProfit", 0);
                Point           = DBTool.GetDoubleFromRow(row, "Point", 0);
                RealName        = DBTool.GetStringFromRow(row, "RealName", "");
                Mobile          = DBTool.GetStringFromRow(row, "Mobile", "");
                Telphone        = DBTool.GetStringFromRow(row, "Telphone", "");
                Email           = DBTool.GetStringFromRow(row, "Email", "");
                Company         = DBTool.GetStringFromRow(row, "Company", "");
                Address         = DBTool.GetStringFromRow(row, "Address", "");
                DeptName        = DBTool.GetStringFromRow(row, "DeptName", "");
                Invoice         = DBTool.GetStringFromRow(row, "Invoice", "");
                Invoice_Name    = DBTool.GetStringFromRow(row, "Invoice_Name", "");
                Invoice_Type    = DBTool.GetStringFromRow(row, "Invoice_Type", "");
                Invoice_Content = DBTool.GetStringFromRow(row, "Invoice_Content", "");
                Pay_method      = DBTool.GetStringFromRow(row, "Pay_method", "");
                Memo            = DBTool.GetStringFromRow(row, "Memo", "");
                UserId          = DBTool.GetIntFromRow(row, "UserId", 0);
                SaveNum         = DBTool.GetIntFromRow(row, "SaveNum", 0);
                PrintNum        = DBTool.GetIntFromRow(row, "PrintNum", 0);
                PrintDateTime   = DBTool.GetDateTimeFromRow(row, "PrintDateTime");
                OrderType       = DBTool.GetStringFromRow(row, "OrderType", "");
                PayStatus       = DBTool.GetStringFromRow(row, "PayStatus", "");
                IsInner         = DBTool.GetIntFromRow(row, "IsInner", 0);
                BranchId        = DBTool.GetIntFromRow(row, "BranchId", 0);
                RowNum          = DBTool.GetIntFromRow(row, "RowNum", 0);
                IsCopied        = DBTool.GetIntFromRow(row, "IsCopied", 0);
                RawOrderId      = DBTool.GetIntFromRow(row, "RawOrderId", 0);
                UpdateTime      = DBTool.GetDateTimeFromRow(row, "UpdateTime");
                Emergency       = DBTool.GetIntFromRow(row, "Emergency", 0);
                ChargeOff       = DBTool.GetDoubleFromRow(row, "ChargeOff", 0);
                PaidMoney       = DBTool.GetDoubleFromRow(row, "PaidMoney", 0);
                TPI_OrderId     = DBTool.GetIntFromRow(row, "TPI_OrderId", 0);
                SalesId         = DBTool.GetIntFromRow(row, "SalesId", 0);
                SecrecyId       = DBTool.GetIntFromRow(row, "SecrecyId", 0);
                DeptId          = DBTool.GetIntFromRow(row, "DeptId", 0);
                ApplyId         = DBTool.GetIntFromRow(row, "ApplyId", 0);
                TPI_Name        = DBTool.GetStringFromRow(row, "TPI_Name", "");
                GUID            = DBTool.GetStringFromRow(row, "GUID", "");
                IsStorage       = DBTool.GetIntFromRow(row, "IsStorage", 0);
                IsDelete        = DBTool.GetIntFromRow(row, "IsDelete", 0);
                Tax             = DBTool.GetDoubleFromRow(row, "Tax", 0);
                TaxRate         = DBTool.GetDoubleFromRow(row, "TaxRate", 0);
                TaxGrossProfit  = DBTool.GetDoubleFromRow(row, "TaxGrossProfit", 0);
                return(true);
            }
            return(false);
        }
Example #13
0
 private int modifyVIPApply(VIPApply apply, List <VIPApplyDetail> details, int OperaterId)
 {
     if (apply.Save() > 0)
     {
         //记录修改明细
         //循环新表处理 修改数量的商品 和 新增商品
         VIPApplyDetail vad = new VIPApplyDetail();
         vad.ApplyId = apply.Id;
         DataTable dtOld = vad.GetApplyDetailByApplyId().Tables[0];
         for (int i = 0; i < details.Count; i++)
         {
             DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", details[i].GoodsId));
             if (rows.Length == 1)//有这个商品
             {
                 int oldNum = DBTool.GetIntFromRow(rows[0], "Num", 0);
                 if (details[i].Num != oldNum)//数量改变需要修改
                 {
                     vad.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                     vad.Load();
                     vad.Num = details[i].Num;
                     if (vad.Save() > 0)
                     {
                         //按专柜中没有组合商品处理
                         //修改明细记录
                         VIPApplyModify vam = new VIPApplyModify();
                         vam.ApplyId    = apply.Id;
                         vam.GoodsId    = vad.GoodsId;
                         vam.OldNum     = oldNum;
                         vam.NewNum     = vad.Num;
                         vam.OperaterId = OperaterId;//记录操作人
                         vam.UpdateTime = DateTime.Now;
                         vam.Save();
                     }
                 }
             }
             else //新增商品
             {
                 VIPApplyDetail svad = new VIPApplyDetail();
                 svad.ApplyId  = apply.Id;
                 svad.GoodsId  = details[i].GoodsId;
                 svad.Num      = details[i].Num;
                 svad.VIPPrice = details[i].VIPPrice;
                 if (svad.Save() > 0)
                 {
                     //修改明细记录
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = svad.GoodsId;
                     vam.OldNum     = 0;
                     vam.NewNum     = svad.Num;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
         //循环旧表找到删除的商品 记录明细
         foreach (DataRow row in dtOld.Rows)
         {
             int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
             int  oldnum   = DBTool.GetIntFromRow(row, "num", 0);
             bool isExsist = false;
             for (int i = 0; i < details.Count; i++)
             {
                 if (details[i].GoodsId == goodsId)
                 {
                     isExsist = true;
                     break;
                 }
             }
             if (isExsist == false)
             {
                 VIPApplyDetail dvad = new VIPApplyDetail();
                 //新申请单中无 此项
                 dvad.Id = DBTool.GetIntFromRow(row, "Id", 0);
                 if (dvad.Delete())//删除申请单明细中的某一商品记录
                 {
                     //记录申请单删除某一商品
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = goodsId;
                     vam.OldNum     = oldnum;
                     vam.NewNum     = 0;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
     }
     return(apply.Id);
 }
Example #14
0
        /// <summary>
        /// 部分付款
        /// </summary>
        /// <param name="ChargeOff"></param>
        /// <param name="ReceiveMoney"></param>
        private void UpdateOrderPayStatusBFFK(double ChargeOff, double ReceiveMoney)
        {
            //将该对账单所有的订单收款状态初始化
            string sql = string.Format(@"update [Order] set PayStatus='已对账',PaidMoney=0,ChargeOff=0 
            where Id in( select OrderId from OrderStatementDetail where OrderStatementId={0})", this.Id);

            m_dbo.ExecuteNonQuery(sql);

            //如果销账金额为0,直接退出
            if (PayStatus == CommenClass.PayStatus.未付款.ToString())
            {
                return;
            }
            //读取改对账单对应的所用订单列表
            sql = string.Format("select * from View_OrderStatementDetail  where OrderStatementId={0} order by OrderId ", this.Id);
            DataSet ds = m_dbo.GetDataSet(sql);
            //循环 订单列表,按照时间先后进行销账处理
            double allchargeoff    = ChargeOff;
            double allreceivemoney = ReceiveMoney;

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row       = ds.Tables[0].Rows[i];
                int     orderId   = DBTool.GetIntFromRow(row, "OrderId", 0);
                double  summoney  = Math.Round(DBTool.GetDoubleFromRow(row, "SumMoney", 0), 2);
                string  paystatus = CommenClass.PayStatus.已付款.ToString();
                double  chargeoff = summoney;
                double  paidmoney = summoney;
                if (ChargeOff >= 0)//正数对账单
                {
                    if (allchargeoff <= 0)
                    {
                        break;
                    }
                    if (Math.Round(allchargeoff, 2) < summoney)
                    {
                        chargeoff = Math.Round(allchargeoff, 2);
                        paystatus = CommenClass.PayStatus.部分付款.ToString();
                    }
                    if (Math.Round(allreceivemoney) < Math.Round(summoney))
                    {
                        paidmoney = Math.Round(allreceivemoney, 2);
                    }
                }
                else//负数对账单
                {
                    if (allchargeoff >= 0)
                    {
                        break;
                    }
                    if (Math.Round(allchargeoff, 2) > summoney)
                    {
                        chargeoff = Math.Round(allchargeoff, 2);
                        paystatus = CommenClass.PayStatus.部分付款.ToString();
                    }
                    if (Math.Round(allreceivemoney) > Math.Round(summoney))
                    {
                        paidmoney = Math.Round(allreceivemoney, 2);
                    }
                }
                allchargeoff    -= chargeoff;
                allchargeoff     = Math.Round(allchargeoff, 2);
                allreceivemoney -= paidmoney;
                allreceivemoney  = Math.Round(allreceivemoney, 2);
                sql              = string.Format("update [Order] set PayStatus='{0}',PaidMoney={1},ChargeOff={2} where Id={3}", paystatus, paidmoney, chargeoff, orderId);
                m_dbo.ExecuteNonQuery(sql);
            }
        }
Example #15
0
        /// <summary>
        /// 商品汇总单拆分采购单
        /// </summary>
        /// <param name="NeedToPurchaseId"></param>
        /// <param name="branchId"></param>
        /// <param name="StoreId"></param>
        /// <returns></returns>
        public bool PurchaseSave(int NeedToPurchaseId, int branchId, int StoreId)
        {
            DataTable dtNeedToPurchaseDetail = ReadNeedToPurchaseDetail(NeedToPurchaseId).Tables[0];

            if (dtNeedToPurchaseDetail.Rows.Count > 0)
            {
                int    SId         = 0;
                double taxRate     = 0;
                int    isTax       = 0;
                string invoiceType = "";
                int    SupplierId  = 0;
                foreach (DataRow dr in dtNeedToPurchaseDetail.Rows)
                {
                    SupplierId  = DBTool.GetIntFromRow(dr, "SupplierId", 0);
                    taxRate     = DBTool.GetDoubleFromRow(dr, "SprTaxRate", 0.17);
                    invoiceType = DBTool.GetStringFromRow(dr, "SprInvoiceType", "");
                    switch (invoiceType)
                    {
                    case "无发票":
                        isTax   = 0;
                        taxRate = 0;
                        break;

                    case "增票":
                        isTax = 1;
                        break;

                    case "普票":
                        isTax = 2;
                        break;

                    default:
                        isTax   = 1;
                        taxRate = 0.17;
                        break;
                    }
                    int      UserId       = DBTool.GetIntFromRow(dr, "UserId", 0);
                    string   PurchaseType = DBTool.GetStringFromRow(dr, "PurchaseType", "");
                    Purchase p            = new Purchase();
                    p.BranchId         = branchId;
                    p.NeedToPurchaseId = NeedToPurchaseId;
                    p.PurchaseStatus   = CommenClass.PurchaseStatus.未处理.ToString();
                    p.PurchaseType     = PurchaseType;
                    p.UserId           = 0;
                    p.StoreId          = StoreId;
                    p.SupplierId       = SupplierId;
                    p.PurchaseUserId   = UserId;
                    p.IsTax            = isTax;
                    p.TaxRate          = taxRate;
                    int purchaseId = p.Save();
                    if (purchaseId > 0)
                    {
                        string sql = string.Format(@"insert into PurchaseDetail(PurchaseId,GoodsId,StoreId,Model,BillsPrice,InPrice,Num,Amount,ReceivedNum,OldStore,OldAC,Emergency,TaxInPrice)
                                                                        select {0},
                                                                               GoodsId,
                                                                               {1},
                                                                               '',
                                                                               InPrice,
                                                                               (case when {7}=0 then InPrice*1.25 when {7}=1 then InPrice/(1+{6}) when {7}=2 then InPrice end),
                                                                               -LackNum,
                                                                               (InPrice * (-LackNum)),
                                                                               0,
                                                                               {1},
                                                                               InPrice,
                                                                               Emergency,
                                                                               (case when {7}=0 then InPrice*1.25*1.17 when {7}=1 then InPrice when {7}=2 then InPrice*(1+{6}) end)
                                                                       from NeedToPurchaseDetail where NeedToPurchaseId={2} and SupplierId={3} and UserId={4}  and LackNum<0;
                         update Purchase set SumMoney=(select ISNULL(SUM(Amount),0) from PurchaseDetail where PurchaseId={0}),
                                                  Tax=(select ISNULL(SUM(Amount),0) from PurchaseDetail where PurchaseId={0})/(1+{6})*{6}  where Id={0}", purchaseId, StoreId, NeedToPurchaseId, SupplierId, UserId, PurchaseType, taxRate, isTax);
                        m_dbo.ExecuteNonQuery(sql);
                        SId = SupplierId;
                    }
                }
                NeedToPurchase ntp = new NeedToPurchase();
                ntp.AddStatus(NeedToPurchaseId);
                return(true);
            }
            return(false);
        }