/// <summary>
        /// 更新一条数据
        /// </summary>
        public void UpdateFeesSubjectInfo(FeesSubjectInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbFeesSubjectInfo set ");
            strSql.Append("fName=@fName,");
            strSql.Append("fAppendTime=@fAppendTime,");
            strSql.Append("FeesSubjectClassID=@FeesSubjectClassID,");
            strSql.Append("fCode=@fCode,");
            strSql.Append("fDebitCredit=@fDebitCredit");
            strSql.Append(" where FeesSubjectID=@FeesSubjectID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FeesSubjectID",      SqlDbType.Int,        4),
                new SqlParameter("@fName",              SqlDbType.VarChar,   50),
                new SqlParameter("@fAppendTime",        SqlDbType.DateTime),
                new SqlParameter("@FeesSubjectClassID", SqlDbType.Int,        4),
                new SqlParameter("@fCode",              SqlDbType.VarChar,   50),
                new SqlParameter("@fDebitCredit",       SqlDbType.Int,        4),
            };
            parameters[0].Value = model.FeesSubjectID;
            parameters[1].Value = model.fName;
            parameters[2].Value = model.fAppendTime;
            parameters[3].Value = model.FeesSubjectClassID;
            parameters[4].Value = model.fCode;
            parameters[5].Value = model.fDebitCredit;

            DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddFeesSubjectInfo(FeesSubjectInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbFeesSubjectInfo(");
            strSql.Append("fName,fAppendTime,FeesSubjectClassID,fCode,fDebitCredit)");
            strSql.Append(" values (");
            strSql.Append("@fName,@fAppendTime,@FeesSubjectClassID,@fCode,@fDebitCredit)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fName",              SqlDbType.VarChar,   50),
                new SqlParameter("@fAppendTime",        SqlDbType.DateTime),
                new SqlParameter("@FeesSubjectClassID", SqlDbType.Int,        4),
                new SqlParameter("@fCode",              SqlDbType.VarChar,   50),
                new SqlParameter("@fDebitCredit",       SqlDbType.Int,        4),
            };
            parameters[0].Value = model.fName;
            parameters[1].Value = model.fAppendTime;
            parameters[2].Value = model.FeesSubjectClassID;
            parameters[3].Value = model.fCode;
            parameters[4].Value = model.fDebitCredit;

            object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            Act = HTTPRequest.GetString("Act");
            if (Act.Trim() == "")
            {
                StoresID = HTTPRequest.GetInt("StoresID", 0);
            }
            else if (Act == "com")
            {
                Feeid = HTTPRequest.GetInt("Feeid", 0);
            }
            try
            {
                bDate = DateTime.Parse(HTTPRequest.GetString("bDate") + "  00:00:00");
                eDate = DateTime.Parse(HTTPRequest.GetString("eDate") + " 23:59:59");
                if (StoresID > 0)
                {
                    si    = tbStoresInfo.GetStoresInfoModel(StoresID);
                    dList = DataUtils.Get_Fees_by_StoresID(bDate, eDate, StoresID);
                    if (dList != null)
                    {
                        foreach (DataRow dr in dList.Rows)
                        {
                            AllSumValue += Convert.ToDecimal(dr["mFees"]);
                        }
                    }
                }

                if (Feeid > 0)
                {
                    fs    = tbFeesSubjectInfo.GetFeesSubjectInfoModel(Feeid);
                    dList = DataUtils.Get_Fees_by_FeesSubjectID(bDate, eDate, Feeid);
                    if (dList != null)
                    {
                        foreach (DataRow dr in dList.Rows)
                        {
                            AllSumValue += Convert.ToDecimal(dr["mFees"]);
                        }
                    }
                }
                if (StoresID <= 0 && Feeid <= 0)
                {
                    AddErrLine("参数错误!");
                }
            }
            catch (Exception ex) {
                AddErrLine("参数错误!" + ex.Message);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FeesSubjectInfo GetFeesSubjectInfoModelByName(string fName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 FeesSubjectID,fName,fAppendTime,FeesSubjectClassID,fCode,fDebitCredit from tbFeesSubjectInfo ");
            strSql.Append(" where fName=@fName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fName", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = fName;

            FeesSubjectInfo model = new FeesSubjectInfo();
            DataSet         ds    = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["FeesSubjectID"].ToString() != "")
                {
                    model.FeesSubjectID = int.Parse(ds.Tables[0].Rows[0]["FeesSubjectID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FeesSubjectClassID"].ToString() != "")
                {
                    model.FeesSubjectClassID = int.Parse(ds.Tables[0].Rows[0]["FeesSubjectClassID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["fDebitCredit"].ToString() != "")
                {
                    model.fDebitCredit = int.Parse(ds.Tables[0].Rows[0]["fDebitCredit"].ToString());
                }
                model.fCode = ds.Tables[0].Rows[0]["fCode"].ToString();
                model.fName = ds.Tables[0].Rows[0]["fName"].ToString();
                if (ds.Tables[0].Rows[0]["fAppendTime"].ToString() != "")
                {
                    model.fAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["fAppendTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void UpdateFeesSubjectInfo(FeesSubjectInfo model)
 {
     DatabaseProvider.GetInstance().UpdateFeesSubjectInfo(model);
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int AddFeesSubjectInfo(FeesSubjectInfo model)
 {
     return(DatabaseProvider.GetInstance().AddFeesSubjectInfo(model));
 }
Пример #7
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("1"))
                {
                    Act = HTTPRequest.GetString("Act");
                    FeesSubjectClass   = Caches.GetFeesSubjectClassInfoToHTML();
                    fName              = Utils.ChkSQL(HTTPRequest.GetString("fName"));
                    FeesSubjectClassID = HTTPRequest.GetInt("FeesSubjectClassID", 0);
                    fCode              = Utils.ChkSQL(HTTPRequest.GetString("fCode"));
                    fDebitCredit       = HTTPRequest.GetInt("fDebitCredit", 0);
                    if (Act == "Edit")
                    {
                        FeesSubjectID = Utils.StrToInt(HTTPRequest.GetString("fid"), 0);

                        FeesSubject = tbFeesSubjectInfo.GetFeesSubjectInfoModel(FeesSubjectID);
                    }
                    if (ispost)
                    {
                        FeesSubject.FeesSubjectClassID = FeesSubjectClassID;
                        FeesSubject.fCode        = fCode;
                        FeesSubject.fDebitCredit = fDebitCredit;
                        if (Act == "Add")
                        {
                            if (!tbFeesSubjectInfo.ExistsFeesSubjectInfo(fName))
                            {
                                FeesSubject.fName       = fName;
                                FeesSubject.fAppendTime = fAppendTime;

                                if (tbFeesSubjectInfo.AddFeesSubjectInfo(FeesSubject) > 0)
                                {
                                    AddMsgLine("创建成功!");
                                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                }
                                else
                                {
                                    AddErrLine("创建失败!");
                                    AddScript("window.setTimeout('history.back(1);',1000);");
                                }
                            }
                            else
                            {
                                AddErrLine("费用科目:" + fName + ",已存在,请更换!");
                                AddScript("window.setTimeout('history.back(1);',1000);");
                            }
                        }
                        if (Act == "Edit")
                        {
                            if (FeesSubjectID > 0)
                            {
                                if (!tbFeesSubjectInfo.ExistsFeesSubjectInfo(fName) || FeesSubject.fName == fName)
                                {
                                    FeesSubject.fName = fName;
                                    try
                                    {
                                        tbFeesSubjectInfo.UpdateFeesSubjectInfo(FeesSubject);
                                        AddMsgLine("修改成功!");
                                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                    }
                                    catch (Exception ex)
                                    {
                                        AddErrLine("修改失败!<br/>" + ex);
                                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                    }
                                }
                                else
                                {
                                    AddErrLine("费用科目:" + fName + ",已存在,请更换!");
                                    AddScript("window.setTimeout('history.back(1);',1000);");
                                }
                            }
                            else
                            {
                                AddErrLine("参数错误,修改失败!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                    }
                    else
                    {
                        if (Act == "Add")
                        {
                            FeesSubject.fName = "";
                        }

                        if (Act == "Del")
                        {
                            try
                            {
                                tbFeesSubjectInfo.DeleteFeesSubjectInfo(HTTPRequest.GetString("fid"));
                                AddMsgLine("删除成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            catch (Exception ex)
                            {
                                AddErrLine("删除失败!<br/>" + ex);
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Пример #8
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-1"))
                {
                    if (ispost)
                    {
                        int       sType            = Utils.StrToInt(HTTPRequest.GetString("sType"), 0);
                        string    PathStr          = Utils.GetMapPath(config.DataPath.ToString());
                        string    fileExtension    = "";
                        string    fileName         = "";
                        string    thispath         = DateTime.Now.Year + "-" + DateTime.Now.Month;
                        ArrayList filearr          = new ArrayList();
                        int       importdata_count = 0;

                        if (!Directory.Exists(PathStr + thispath))
                        {
                            Directory.CreateDirectory(PathStr + thispath);
                        }

                        //文件上传
                        HttpFileCollection files = HttpContext.Current.Request.Files;
                        try
                        {
                            if (files.Count > 0)
                            {
                                for (int i = 0; i < files.Count; i++)
                                {
                                    HttpPostedFile postedFile = files[i];
                                    fileName = System.IO.Path.GetFileName(postedFile.FileName);
                                    if (Utils.ChkSQL(fileName) != "")
                                    {
                                        fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
                                        if (fileExtension == ".xls")
                                        {
                                            postedFile.SaveAs(PathStr + thispath + "/" + fileName);
                                            filearr.Add(PathStr + thispath + "/" + fileName);
                                        }
                                    }
                                }
                            }
                            if (filearr.Count > 0)
                            {
                                MarketingFeesInfo mi = new MarketingFeesInfo();
                                StoresInfo        si = new StoresInfo();
                                FeesSubjectInfo   fi = new FeesSubjectInfo();
                                StaffInfo         ft = new StaffInfo();
                                try
                                {
                                    for (int j = 0; j < filearr.Count; j++)
                                    {
                                        try
                                        {
                                            DataSet   ds = Excels.ExcelToDataTable(filearr[j].ToString());
                                            DataTable dt = new DataTable();
                                            try
                                            {
                                                dt = ds.Tables[0];
                                                foreach (DataRow dr in dt.Rows)
                                                {
                                                    mi.mAppendTime = DateTime.Now;


                                                    if (sType == 0)//营销费用
                                                    {
                                                        if (dr[0].ToString() != "" && dr[1].ToString() != "" && dr[2].ToString() != "" && dr[3].ToString() != "" && dr[4].ToString() != "")
                                                        {
                                                            if (Utils.IsNumeric(dr[3].ToString()))
                                                            {
                                                                si = tbStoresInfo.GetStoresInfoModelByName(dr[2].ToString().Trim());
                                                                if (si == null)
                                                                {
                                                                    si = tbStoresInfo.GetStoresInfoModelByCode(dr[1].ToString().Trim());
                                                                }
                                                                if (si != null)
                                                                {
                                                                    mi.StoresID = si.StoresID;
                                                                }
                                                                fi = tbFeesSubjectInfo.GetFeesSubjectInfoModelByName(dr[4].ToString().Trim());
                                                                if (fi != null)
                                                                {
                                                                    mi.FeesSubjectID = fi.FeesSubjectID;
                                                                }

                                                                mi.mRemark   = dr[5].ToString().Trim();
                                                                mi.mFees     = decimal.Parse(Utils.StrToFloat(dr[3].ToString().Trim(), 0).ToString());
                                                                mi.mDateTime = DateTime.Parse(dr[0].ToString().Trim());
                                                                mi.mType     = 0;
                                                                mi.StaffID   = 0;

                                                                if (tbMarketingFeesInfo.AddMarketingFeesInfo(mi) > 0)
                                                                {
                                                                    importdata_count++;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (sType == 1)//公司费用
                                                    {
                                                        if (dr[0].ToString() != "" && dr[1].ToString() != "" && dr[2].ToString() != "" && dr[3].ToString() != "")
                                                        {
                                                            if (Utils.IsNumeric(dr[2].ToString()))
                                                            {
                                                                mi.StoresID  = 0;
                                                                mi.mDateTime = DateTime.Parse(dr[0].ToString().Trim());
                                                                fi           = tbFeesSubjectInfo.GetFeesSubjectInfoModelByName(dr[1].ToString().Trim());
                                                                if (fi != null)
                                                                {
                                                                    mi.FeesSubjectID = fi.FeesSubjectID;
                                                                }
                                                                mi.mFees = decimal.Parse(Utils.StrToFloat(dr[2].ToString().Trim(), 0).ToString());
                                                                ft       = tbStaffInfo.GetStaffInfoModelByName(dr[3].ToString().Trim());
                                                                if (ft != null)
                                                                {
                                                                    mi.StaffID = ft.StaffID;
                                                                }
                                                                mi.mType   = 1;
                                                                mi.mRemark = dr[4].ToString().Trim();

                                                                if (tbMarketingFeesInfo.AddMarketingFeesInfo(mi) > 0)
                                                                {
                                                                    importdata_count++;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (sType == 2)//收入
                                                    {
                                                        if (dr[0].ToString() != "" && dr[1].ToString() != "" && dr[2].ToString() != "")
                                                        {
                                                            if (Utils.IsNumeric(dr[1].ToString()))
                                                            {
                                                                mi.StoresID  = 0;
                                                                mi.mDateTime = DateTime.Parse(dr[0].ToString().Trim());
                                                                if (dr[3].ToString().Trim() != "")
                                                                {
                                                                    fi = tbFeesSubjectInfo.GetFeesSubjectInfoModelByName(dr[3].ToString().Trim());
                                                                    if (fi != null)
                                                                    {
                                                                        mi.FeesSubjectID = fi.FeesSubjectID;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    mi.FeesSubjectID = 0;
                                                                }
                                                                mi.mFees = decimal.Parse(Utils.StrToFloat(dr[1].ToString().Trim(), 0).ToString());
                                                                ft       = tbStaffInfo.GetStaffInfoModelByName(dr[2].ToString().Trim());
                                                                if (ft != null)
                                                                {
                                                                    mi.StaffID = ft.StaffID;
                                                                }
                                                                mi.mIsIncomeExpenditure = 1;
                                                                mi.mType   = -1;
                                                                mi.mRemark = dr[4].ToString().Trim();

                                                                if (tbMarketingFeesInfo.AddMarketingFeesInfo(mi) > 0)
                                                                {
                                                                    importdata_count++;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            finally
                                            {
                                                ds.Clear();
                                                ds.Dispose();
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            AddErrLine("<b>文件格式错误,请将 Xls 文件用 Excel 另存后再导入!</b>:<br>" + ex);
                                            //AddScript("window.setTimeout('history.back(1);',5000);");
                                        }
                                    }
                                    if (importdata_count > 0)
                                    {
                                        AddMsgLine("数据导入成功!共导入数据[" + importdata_count.ToString() + "]条.");
                                        AddScript("window.setTimeout('window.parent.HidBox();',5000);");
                                    }
                                    else
                                    {
                                        AddErrLine("系统忙!导入失败!");
                                        //AddScript("window.setTimeout('history.back(1);',1000);");
                                    }
                                }
                                finally
                                {
                                    mi = null;
                                    si = null;
                                    ft = null;
                                }
                            }
                            else
                            {
                                AddErrLine("为发现任何数据!导入失败!");
                                AddScript("window.setTimeout('history.back(1);',1000);");
                            }
                        }
                        finally
                        {
                            files = null;
                            filearr.Clear();
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }