Beispiel #1
0
        /// <summary>
        /// 检测用户是否已存在
        /// </summary>
        /// <returns></returns>
        public string CheckUserName()
        {
            string   UserName = Request.QueryString["UserName"];
            usersbll bll      = new usersbll();

            return(bll.CheckUserName(UserName));
        }
Beispiel #2
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <returns></returns>
        public string UserRegistered()
        {
            Dictionary <string, string> Dic = new Dictionary <string, string>();

            if (Request.QueryString["CheckCode"] != Session["Code"].ToString())
            {
                return("验证码错误!");
            }

            //helpcommon.PasswordHelp.encrypt(password)
            //密码:
            string password = helpcommon.PasswordHelp.encrypt(Request.QueryString["Password"]);

            password = helpcommon.PasswordHelp.encrypt(password);

            Dic.Add("UserName", Request.QueryString["UserName"]);
            Dic.Add("Password", password);
            Dic.Add("RealName", Request.QueryString["RealName"]);
            Dic.Add("Sex", Request.QueryString["Sex"]); //0为女生,1为男生
            Dic.Add("txtReTelphone", Request.QueryString["txtReTelphone"]);
            Dic.Add("txtReAddress", Request.QueryString["txtReAddress"]);
            Dic.Add("txtReEmail", Request.QueryString["txtReEmail"]);
            usersbll bll = new usersbll();

            return(bll.UserRegistered(Dic));
        }
Beispiel #3
0
        public bool insert(usersbll u)
        {
            //Create a boolean variable and set its value to false and return it
            bool issucess = false;
            //MEthod to connect Database
            connclass     c    = new connclass();
            SqlConnection conn = new SqlConnection(c.connection);

            try
            {
                //SQL Query to insert Data in DAtabase
                string query = "Insert into tbl_users(user_name,user_type,password,email,cnic,adress,phone_no,added_by,added_date)Values(@user_name,@user_type,@password,@email,@cnic,@adress,@phone_no,@added_by,@added_date)";
                //For Executing Command
                SqlCommand cmd = new SqlCommand(query, conn);
                //Passing Values to the Variables
                cmd.Parameters.AddWithValue("@user_name", u.user_name);
                cmd.Parameters.AddWithValue("@user_type", u.user_type);
                cmd.Parameters.AddWithValue("@password", u.password);
                cmd.Parameters.AddWithValue("@email", u.email);
                cmd.Parameters.AddWithValue("@cnic", u.cnic);
                cmd.Parameters.AddWithValue("@adress", u.adress);
                cmd.Parameters.AddWithValue("@phone_no", u.phone_no);
                cmd.Parameters.AddWithValue("@added_by", u.added_by);
                cmd.Parameters.AddWithValue("@added_date", u.added_date);
                //Database Connection Open
                conn.Open();
                //To execute non query
                int row = cmd.ExecuteNonQuery();
                //If the query is executed Successfully then the value to rows will be greater than 0 else it will be less than 0
                if (row > 0)
                {
                    //Query Sucessfull
                    issucess = true;
                }
                else
                {
                    //Query Failed
                    issucess = false;
                }
            }
            catch (Exception ex)
            {
                //Throw Message if any error occurs
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Closing Connection
                conn.Close();
            }

            return(issucess);
        }
Beispiel #4
0
        public bool exist(usersbll u)
        {
            //Create a boolean variable and set its value to false and return it
            bool issuccess = false;
            //MEthod to connect Database
            connclass     c    = new connclass();
            SqlConnection conn = new SqlConnection(c.connection);

            try
            {
                //SQL Query to selecte Data from DAtabase
                string query = "select * from tbl_users where user_name=@user_name AND cnic=@cnic AND email=@email AND phone_no=@phone_no ";
                //For Executing Command
                SqlCommand cmd = new SqlCommand(query, conn);
                //Passing Values to the Variables
                cmd.Parameters.AddWithValue("@user_name", u.user_name);
                cmd.Parameters.AddWithValue("@cnic", u.cnic);
                cmd.Parameters.AddWithValue("@email", u.email);
                cmd.Parameters.AddWithValue("@phone_no", u.phone_no);
                //Getting DAta from dAtabase
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                //TO hold the data from database
                DataTable dt = new DataTable();
                //Database Connection Open
                conn.Open();
                //Fill Data in our DataTable
                adapter.Fill(dt);
                //Checking The rows in DataTable
                if (dt.Rows.Count > 0)
                {
                    //Data Exist
                    issuccess = true;
                }
                else
                {
                    //Data not exist
                    issuccess = false;
                }
            }
            catch (Exception ex)
            {
                //Throw Message if any error occurs
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Closing Connection
                conn.Close();
            }

            return(issuccess);
        }
Beispiel #5
0
        public bool delete(usersbll u)
        {
            //Create a boolean variable and set its value to false and return it
            bool issucess = false;
            //MEthod to connect Database
            connclass     c    = new connclass();
            SqlConnection conn = new SqlConnection(c.connection);

            try
            {
                //SQL Query to delete Data in DAtabase
                string query = "DELETE FROM tbl_users WHERE id=@id";
                //For Executing Command
                SqlCommand cmd = new SqlCommand(query, conn);
                //Passing Values to the Variables
                cmd.Parameters.AddWithValue("@id", u.id);
                //Database Connection Open
                conn.Open();
                //To execute non query
                int row = cmd.ExecuteNonQuery();
                //If the query is executed Successfully then the value to rows will be greater than 0 else it will be less than 0
                if (row > 0)
                {
                    //Query Sucessfull
                    issucess = true;
                }
                else
                {
                    //Query Failed
                    issucess = false;
                }
            }

            catch (Exception ex)
            {
                //Throw Message if any error occurs
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Closing Connection
                conn.Close();
            }

            return(issucess);
        }
Beispiel #6
0
        public usersbll GetIDFromUsername(string username)
        {
            //Connecting user BLL for getting id
            usersbll u = new usersbll();
            //MEthod to connect Database
            connclass     c    = new connclass();
            SqlConnection conn = new SqlConnection(c.connection);
            //TO hold the data from database
            DataTable dt = new DataTable();

            try
            {
                //SQL Query to get Data from DAtabase
                string sql = "SELECT id FROM tbl_users WHERE user_name='" + username + "'";
                //Getting DAta from dAtabase
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
                //Database Connection Open
                conn.Open();
                //Fill Data in our DataTable
                adapter.Fill(dt);
                //Checking The rows in DataTable
                if (dt.Rows.Count > 0)
                {
                    //Getting id from DataTable
                    u.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                //Throw Message if any error occurs
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Closing Connection
                conn.Close();
            }
            return(u);
        }
        /// <summary>
        /// 用户分配店铺
        /// </summary>
        /// <returns></returns>
        public string Allocation()
        {
            string ShopId = Request.Form["ShopId"] == null ? "" : Request.Form["ShopId"].ToString().Trim(',');
            string Id     = Request.Form["UserId"] == null ? "" : Request.Form["UserId"].ToString();

            string[] strShopId = ShopId.Split(',');
            shopbll  sb        = new shopbll();

            if (sb.ClearShopAllocationByManagerId(Id))
            {
                if (strShopId.Length > 0)
                {
                    usersbll usb = new usersbll();
                    for (int i = 0; i < strShopId.Length; i++)
                    {
                        if (usb.ShopIsAllocation(strShopId[i].ToString(), Id))
                        {
                            usb.InsertShopAllocation(strShopId[i].ToString(), Id);
                        }
                    }
                }
            }
            return("");
        }
Beispiel #8
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (Validation1())
            {
                //printPreviewDialog1.Document = printDocument1;
                //printPreviewDialog1.ShowDialog();


                //Gettting Data FRom UI
                inbll.inv_no        = Convert.ToInt32(lblinvoiceno.Text);
                inbll.customer_name = cmbcustomer.Text;
                inbll.total_payable = txtsubtotal.Text;
                inbll.paid_amount   = txtpaidamount.Text;
                inbll.discount      = txtdiscount.Text;
                inbll.due_amount    = txtdueamount.Text;
                inbll.change_amount = txtchangeamount.Text;
                inbll.sales_date    = DateTime.Now;
                //Getting Username of the logged in user
                string   loggedUser = Login.loggedIn;
                usersbll usr        = user.GetIDFromUsername(loggedUser);
                inbll.added_by = usr.id;
                //Inserting Data into DAtabase
                bool w      = indal.insert(inbll);
                bool sucess = false;

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    bool x = false;
                    //Get the Product name and convert it to id
                    string             ProductName = table.Rows[i][0].ToString();
                    string             type1       = table.Rows[i][2].ToString();
                    string             ccode       = table.Rows[i][1].ToString();
                    Manage_Productsbll p           = dal.GetProductIDFromName(ProductName, type1, ccode);
                    prbll.product_id = p.id;

                    prbll.product_name = table.Rows[i][0].ToString();
                    prbll.type         = table.Rows[i][2].ToString();
                    prbll.price        = table.Rows[i][3].ToString();
                    prbll.quantity     = table.Rows[i][4].ToString();
                    prbll.code         = Convert.ToInt32(table.Rows[i][1]);
                    prbll.discount     = txtdiscount.Text;
                    //prbll.total = table.Rows[i][3].ToString();
                    //Getting total value by calculating discount
                    t1          = Convert.ToDouble(txtdiscount.Text);
                    t2          = Convert.ToDouble(table.Rows[i][5]);
                    prbll.total = (t2 - (t2 * t1) / 100).ToString();

                    //Method to get purchase price an multiply it with quantity
                    Manage_Productsbll pr = dal.GetProductpriceFromId(p.id.ToString());
                    purchaseprice        = Convert.ToDouble(pr.purchase_price);
                    prbll.purchase_price = ((Convert.ToDouble(table.Rows[i][4])) * purchaseprice).ToString();

                    prbll.inv_no     = lblinvoiceno.Text;
                    prbll.added_by   = usr.id;
                    prbll.added_date = DateTime.Now;

                    quantity1 = Convert.ToDecimal(prbll.quantity);

                    // Decreasing product quantity in DAtabase
                    bool y = false;
                    y = dal.DecreaseProduct(prbll.product_id, quantity1);

                    // Inserting Data into DAtabase
                    x      = prdal.insert(prbll);
                    sucess = w && x && y;
                }

                if (sucess == true)
                {
                    MessageBox.Show("Transaction Completed Sucessfully");

                    //Celar the Data Grid View and Clear all the TExtboxes
                    dgvinvoice.DataSource = null;
                    dgvinvoice.Rows.Clear();

                    txttotal.Text        = "";
                    txtdiscount.Text     = "";
                    txtsubtotal.Text     = "";
                    txtpaidamount.Text   = "";
                    txtdueamount.Text    = "";
                    txtchangeamount.Text = "";
                    cmbcustomer.Text     = "";
                    txtcomment.Text      = "0";
                    //To refresh stock in Data grid view
                    DataTable dt = dal.select();
                    dgvstock.DataSource = dt;

                    ToGetInvoiceID();
                }
                else
                {
                    //Transaction Failed
                    MessageBox.Show("Transaction Failed");
                }
            }
        }
Beispiel #9
0
        private void btncomplete_Click(object sender, EventArgs e)
        {
            if (Validation1())
            {
                //printPreviewDialog1.Document = printDocument1;
                //printPreviewDialog1.ShowDialog();


                //Gettting Data FRom UI
                inbll.inv_no        = Convert.ToInt32(lblinvoiceno.Text);
                inbll.customer_name = cmbcustomer.Text;
                inbll.total_payable = txtsubtotal.Text;
                inbll.paid_amount   = txtpaidamount.Text;
                inbll.discount      = txtdiscount.Text;
                inbll.due_amount    = txtdueamount.Text;
                inbll.change_amount = txtchangeamount.Text;
                inbll.sales_date    = DateTime.Now;
                //Getting Username of the logged in user
                string   loggedUser = Login.loggedIn;
                usersbll usr        = user.GetIDFromUsername(loggedUser);
                inbll.added_by = usr.id;
                //Inserting Data into DAtabase
                bool w      = indal.insert(inbll);
                bool sucess = false;

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    bool x = false;
                    //Get the Product name and convert it to id
                    string             ProductName = table.Rows[i][0].ToString();
                    string             type1       = table.Rows[i][2].ToString();
                    string             ccode       = table.Rows[i][1].ToString();
                    Manage_Productsbll p           = dal.GetProductIDFromName(ProductName, type1, ccode);
                    prbll.product_id = p.id;

                    prbll.product_name = table.Rows[i][0].ToString();
                    prbll.type         = table.Rows[i][2].ToString();
                    prbll.price        = table.Rows[i][3].ToString();
                    prbll.quantity     = table.Rows[i][4].ToString();
                    prbll.code         = Convert.ToInt32(table.Rows[i][1]);
                    prbll.discount     = txtdiscount.Text;
                    //prbll.total = table.Rows[i][3].ToString();
                    //Getting total value by calculating discount
                    t1          = Convert.ToDouble(txtdiscount.Text);
                    t2          = Convert.ToDouble(table.Rows[i][5]);
                    prbll.total = (t2 - (t2 * t1) / 100).ToString();

                    //Method to get purchase price an multiply it with quantity
                    Manage_Productsbll pr = dal.GetProductpriceFromId(p.id.ToString());
                    purchaseprice        = Convert.ToDouble(pr.purchase_price);
                    prbll.purchase_price = ((Convert.ToDouble(table.Rows[i][4])) * purchaseprice).ToString();

                    prbll.inv_no     = lblinvoiceno.Text;
                    prbll.added_by   = usr.id;
                    prbll.added_date = DateTime.Now;

                    quantity1 = Convert.ToDecimal(prbll.quantity);

                    // Decreasing product quantity in DAtabase
                    bool y = false;
                    y = dal.DecreaseProduct(prbll.product_id, quantity1);

                    // Inserting Data into DAtabase
                    x      = prdal.insert(prbll);
                    sucess = w && x && y;
                }

                if (sucess == true)
                {
                    //code to print Bill
                    DGVPrinter printer = new DGVPrinter();
                    printer.Title               = "\r \r Time Paint & Hardware Store";
                    printer.SubTitle            = "Khokhar Plaza, Near Alied Bank, Main Behria Enclave Road \r \n Phone: 031659007044 \r \r \r \r \r \r Invoice #:" + lblinvoiceno.Text + "\r";
                    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    printer.PageNumbers         = true;
                    printer.PageNumberInHeader  = false;
                    printer.PorportionalColumns = true;
                    printer.HeaderCellAlignment = StringAlignment.Near;
                    printer.Footer              = "Grand Total: " + txtsubtotal.Text + " \r \r \r \r \r \r \r \r \r \r \r \r" + "Total Paid:" + txtpaidamount.Text + " \r \n" + "Thank You, for doing business with us. \n";
                    //printer.PageText = "Developed By: \r \r \r Engr. Azhar Mir \r \r \r \r \r \r \r \r \r Mailing Contact: \r \r \r [email protected] \n";
                    printer.FooterSpacing = 15;
                    printer.PrintDataGridView(dgvinvoice);


                    MessageBox.Show("Transaction Completed Sucessfully");

                    //Celar the Data Grid View and Clear all the TExtboxes
                    dgvinvoice.DataSource = null;
                    dgvinvoice.Rows.Clear();

                    txttotal.Text        = "";
                    txtdiscount.Text     = "";
                    txtsubtotal.Text     = "";
                    txtpaidamount.Text   = "";
                    txtdueamount.Text    = "";
                    txtchangeamount.Text = "";
                    cmbcustomer.Text     = "";
                    txtcomment.Text      = "0";
                    //To refresh stock in Data grid view
                    DataTable dt = dal.select();
                    dgvstock.DataSource = dt;

                    ToGetInvoiceID();
                }
                else
                {
                    //Transaction Failed
                    MessageBox.Show("Transaction Failed");
                }
            }
        }
        public static int Savemenuid     = 0; //记录菜单编号
        public string GetAllProduct()
        {
            usersbll             usb = new usersbll();
            PublicHelpController ph  = new PublicHelpController();
            ProductStockBLL      psb = new ProductStockBLL();

            #region 查询条件

            string   orderParams            = Request.Form["params"] ?? string.Empty;                                                        //参数
            string[] orderParamss           = helpcommon.StrSplit.StrSplitData(orderParams, ',');                                            //参数集合
            Dictionary <string, string> dic = new Dictionary <string, string>();                                                             //搜索条件

            string Style     = helpcommon.StrSplit.StrSplitData(orderParamss[0], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //货号
            string Scode     = helpcommon.StrSplit.StrSplitData(orderParamss[1], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //款号
            string PriceMin  = helpcommon.StrSplit.StrSplitData(orderParamss[2], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最小价格
            string PriceMax  = helpcommon.StrSplit.StrSplitData(orderParamss[3], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最大价格
            string Season    = helpcommon.StrSplit.StrSplitData(orderParamss[4], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //季节
            string Type      = helpcommon.StrSplit.StrSplitData(orderParamss[5], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //品牌
            string Brand     = helpcommon.StrSplit.StrSplitData(orderParamss[6], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最小库存
            string StockMin  = helpcommon.StrSplit.StrSplitData(orderParamss[7], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最大库存
            string StockMax  = helpcommon.StrSplit.StrSplitData(orderParamss[8], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最小时间
            string Descript  = helpcommon.StrSplit.StrSplitData(orderParamss[9], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty;  //最大时间
            string MinTime   = helpcommon.StrSplit.StrSplitData(orderParamss[10], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty; //类别
            string MaxTime   = helpcommon.StrSplit.StrSplitData(orderParamss[11], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty; //供应商
            string Vencode   = helpcommon.StrSplit.StrSplitData(orderParamss[12], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty; //有图/无图
            string ImageFile = helpcommon.StrSplit.StrSplitData(orderParamss[13], ':')[1].Replace("'", "").Replace("}", "") ?? string.Empty; //有图/无图


            Scode     = Scode == "\'\'" ? string.Empty : Scode;
            Style     = Style == "\'\'" ? string.Empty : Style;
            PriceMax  = PriceMax == "\'\'" ? string.Empty : PriceMax;
            PriceMin  = PriceMin == "\'\'" ? string.Empty : PriceMin;
            Season    = Season == "\'\'" ? string.Empty : Season;
            Brand     = Brand == "\'\'" ? string.Empty : Brand;
            StockMax  = StockMax == "\'\'" ? string.Empty : StockMax;
            StockMin  = StockMin == "\'\'" ? string.Empty : StockMin;
            MinTime   = MinTime == "\'\'" ? string.Empty : MinTime;
            MaxTime   = MaxTime == "\'\'" ? string.Empty : MaxTime;
            Type      = Type == "\'\'" ? string.Empty : Type;
            Vencode   = Vencode == "\'\'" ? string.Empty : Vencode;
            ImageFile = ImageFile == "\'\'" ? string.Empty : ImageFile;
            Descript  = Descript == "\'\'" ? string.Empty : Descript;

            dic.Add("Scode", Scode);
            dic.Add("Style", Style);
            dic.Add("PriceMax", PriceMax);
            dic.Add("PriceMin", PriceMin);
            dic.Add("Season", Season);
            dic.Add("Brand", Brand);
            dic.Add("StockMax", StockMax);
            dic.Add("StockMin", StockMin);
            dic.Add("TimeMin", MinTime);
            dic.Add("TimeMax", MaxTime);
            dic.Add("Type", Type);
            dic.Add("Vencode", Vencode);
            dic.Add("Imagefile", ImageFile);
            dic.Add("Descript", Descript);
            dic.Add("ShopId", "");                              //店铺Id 选货处使用
            dic.Add("isCheckProduct", "");                      //是否为选货查询 选货处使用
            dic.Add("CustomerId", userInfo.User.Id.ToString()); //用户Id

            #endregion
            int roleId = helpcommon.ParmPerportys.GetNumParms(userInfo.User.personaId); //角色ID
            int menuId = helpcommon.ParmPerportys.GetNumParms(Request.Form["menuId"]);  //菜单ID

            int pageIndex = Request.Form["pageIndex"] == null ? 0 : helpcommon.ParmPerportys.GetNumParms(Request.Form["pageIndex"]);
            int pageSize  = Request.Form["pageSize"] == null ? 10 : helpcommon.ParmPerportys.GetNumParms(Request.Form["pageSize"]);

            string[] allTableName = usb.getDataName("productstock");                          //当前列表所有字段
            string[] s            = ph.getFiledPermisson(roleId, menuId, funName.selectName); //获得当前权限字段
            bool     Storage      = ph.isFunPermisson(roleId, menuId, funName.Storage);       //入库权限
            bool     Marker       = ph.isFunPermisson(roleId, menuId, funName.Marker);        //商品标记权限(备注)

            int Count = 0;                                                                    //数据总个数
            psb.SearchShowProductStock(dic, out Count);
            int PageCount = Count % pageSize > 0 ? Count / pageSize + 1 : Count / pageSize;   //数据总页数

            int MinId = pageSize;
            int MaxId = pageSize * (pageIndex - 1);

            DataTable dt = psb.SearchShowProductStock(dic, MinId, MaxId);

            #region  Table表头排序
            string idNuber = "";

            idNuber = allTableName[0];
            for (int i = 0; i < allTableName.Length; i++)   //排序将款号挪到第一列
            {
                if (allTableName[i] == "Style")
                {
                    string styleNuber = allTableName[i];
                    allTableName[0] = styleNuber;
                    allTableName[i] = idNuber;
                }
            }
            string Value = "";
            Value = allTableName[1];
            for (int i = 0; i < allTableName.Length; i++)   //排序将货号挪到第二列
            {
                if (allTableName[i] == "Scode")
                {
                    string temp = allTableName[i];
                    allTableName[1] = Scode;
                    allTableName[i] = Value;
                }
            }
            string Model = "";
            Model = allTableName[2];
            for (int i = 0; i < allTableName.Length; i++)   //排序将型号挪到第三列
            {
                if (allTableName[i] == "Model")
                {
                    string temp = allTableName[i];
                    allTableName[2] = Scode;
                    allTableName[i] = Model;
                }
            }
            string IdNumber = "";
            IdNumber = s[0];
            for (int n = 0; n < s.Length; n++)   //排序将款号挪到第一列
            {
                if (s[n] == "Style")
                {
                    string styleNuber = s[n];
                    s[0] = styleNuber;
                    s[n] = IdNumber;
                }
            }
            string test = "";
            test = s[1];
            for (int n = 0; n < s.Length; n++)   //排序将货号挪到第二列
            {
                if (s[n] == "Scode")
                {
                    string styleNuber = s[n];
                    s[1] = styleNuber;
                    s[n] = test;
                }
            }
            string ModelS = "";
            ModelS = s[2];
            for (int n = 0; n < s.Length; n++)   //排序将货号挪到第二列
            {
                if (s[n] == "Model")
                {
                    string styleNuber = s[n];
                    s[2] = styleNuber;
                    s[n] = ModelS;
                }
            }
            if (s.Contains("Imagefile"))
            {
                string temp = s[3];
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == "Imagefile")
                    {
                        s[i] = temp;
                        s[3] = "Imagefile";
                    }
                }
            }
            #endregion
            StringBuilder Alltable = new StringBuilder();

            #region Table表头
            Alltable.Append("<table id='StcokTable' class='mytable' style='font-size:12px;'><tr style='text-align:center;'>");
            Alltable.Append("<td>序号</td>");
            for (int i = 0; i < s.Length; i++)
            {
                if (allTableName.Contains(s[i]))
                {
                    Alltable.Append("<th>");
                    if (s[i] == "Id")
                    {
                        Alltable.Append("编号");
                    }
                    if (s[i] == "Scode")
                    {
                        Alltable.Append("货号");
                    }
                    if (s[i] == "Bcode")
                    {
                        Alltable.Append("条码1");
                    }
                    if (s[i] == "Bcode2")
                    {
                        Alltable.Append("条码2");
                    }
                    if (s[i] == "Descript")
                    {
                        Alltable.Append("英文描述");
                    }
                    if (s[i] == "Cdescript")
                    {
                        Alltable.Append("中文描述");
                    }
                    if (s[i] == "Unit")
                    {
                        Alltable.Append("单位");
                    }
                    if (s[i] == "Currency")
                    {
                        Alltable.Append("货币");
                    }
                    if (s[i] == "Cat")
                    {
                        Alltable.Append("品牌");
                    }
                    if (s[i] == "Cat1")
                    {
                        Alltable.Append("季节");
                    }
                    if (s[i] == "Cat2")
                    {
                        Alltable.Append("类别");
                    }
                    if (s[i] == "Clolor")
                    {
                        Alltable.Append("颜色");
                    }
                    if (s[i] == "Size")
                    {
                        Alltable.Append("尺寸");
                    }
                    if (s[i] == "Style")
                    {
                        Alltable.Append("款号");
                    }
                    if (s[i] == "Pricea")
                    {
                        Alltable.Append("吊牌价");
                    }
                    if (s[i] == "Priceb")
                    {
                        Alltable.Append("零售价");
                    }
                    if (s[i] == "Pricec")
                    {
                        Alltable.Append("VIP价");
                    }
                    if (s[i] == "Priced")
                    {
                        Alltable.Append("批发价");
                    }
                    if (s[i] == "Pricee")
                    {
                        Alltable.Append("成本价");
                    }
                    if (s[i] == "Disca")
                    {
                        Alltable.Append("折扣1");
                    }
                    if (s[i] == "Discb")
                    {
                        Alltable.Append("折扣2");
                    }
                    if (s[i] == "Discc")
                    {
                        Alltable.Append("折扣3");
                    }
                    if (s[i] == "Discd")
                    {
                        Alltable.Append("折扣4");
                    }
                    if (s[i] == "Disce")
                    {
                        Alltable.Append("折扣5");
                    }
                    if (s[i] == "Vencode")
                    {
                        Alltable.Append("供应商");
                    }
                    if (s[i] == "Model")
                    {
                        Alltable.Append("型号");
                    }
                    if (s[i] == "Rolevel")
                    {
                        Alltable.Append("预警库存");
                    }
                    if (s[i] == "Roamt")
                    {
                        Alltable.Append("最少订货量");
                    }
                    if (s[i] == "Stopsales")
                    {
                        Alltable.Append("停售库存");
                    }
                    if (s[i] == "Loc")
                    {
                        Alltable.Append("店铺");
                    }
                    if (s[i] == "Balance")
                    {
                        Alltable.Append("供应商库存");
                    }
                    if (s[i] == "Lastgrnd")
                    {
                        Alltable.Append("交货日期");
                    }
                    if (s[i] == "Imagefile")
                    {
                        Alltable.Append("缩略图");
                    }
                    if (s[i] == "UserId")
                    {
                        Alltable.Append("操作人");
                    }
                    if (s[i] == "PrevStock")
                    {
                        Alltable.Append("上一次库存");
                    }
                    if (s[i] == "Def2")
                    {
                        Alltable.Append("是否次品");
                    }
                    if (s[i] == "Def3")
                    {
                        Alltable.Append("默认3");
                    }
                    if (s[i] == "Def4")
                    {
                        Alltable.Append("是否开放");
                    }
                    if (s[i] == "Def5")
                    {
                        Alltable.Append("默认5");
                    }
                    if (s[i] == "Def6")
                    {
                        Alltable.Append("默认6");
                    }
                    if (s[i] == "Def7")
                    {
                        Alltable.Append("默认7");
                    }
                    if (s[i] == "Def8")
                    {
                        Alltable.Append("默认8");
                    }
                    if (s[i] == "Def9")
                    {
                        Alltable.Append("默认9");
                    }
                    if (s[i] == "Def10")
                    {
                        Alltable.Append("默认10");
                    }
                    if (s[i] == "Def11")
                    {
                        Alltable.Append("默认11");
                    }
                    Alltable.Append("</th>");
                }
            }
            Alltable.Append("<td><input type='checkbox' id='CheckAll' onchange='checkall()'/>操作</td>");
            Alltable.Append("</tr>");
            #endregion

            #region Table内容
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Alltable.Append("<tr>");
                Alltable.Append("<td>" + (i + pageSize * (pageIndex - 1) + 1) + "</td>");
                int DefCountBalance = psb.GetDefctiveRemarkBalanceCount(psb.SelectVenNameByVencode(dt.Rows[i]["Vencode"].ToString()), dt.Rows[i]["Scode"].ToString());
                for (int j = 0; j < s.Length; j++)
                {
                    if (allTableName.Contains(s[j]))
                    {
                        if (s[j] == "Imagefile")
                        {
                            if (dt.Rows[i]["ImagePath"] != null && dt.Rows[i]["ImagePath"].ToString() != "")
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("<img style='height:50px;width:50px;' onerror='errorImg(this)' src='" + dt.Rows[i]["ImagePath"] + "' />");
                                Alltable.Append("</td>");
                            }
                            else
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("");
                                Alltable.Append("</td>");
                            }
                        }
                        else if (s[j] == "Def2")
                        {
                            string IsState = dt.Rows[i]["Def2"] == null ? "0" : dt.Rows[i]["Def2"].ToString();
                            if (IsState == "1")
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("是");
                                Alltable.Append("</td>");
                            }
                            else
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("否");
                                Alltable.Append("</td>");
                            }
                        }
                        else if (s[j] == "Balance")
                        {
                            int scount = int.Parse(dt.Rows[i]["Balance"].ToString()) - DefCountBalance;
                            Alltable.Append("<td>");
                            Alltable.Append(scount);
                            Alltable.Append("</td>");
                        }
                        else if (s[j] == "Def4")
                        {
                            string def4 = dt.Rows[i]["Def4"] == null ? "2" : dt.Rows[i]["Def4"].ToString();
                            if (def4 != "1")
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("已开放");
                                Alltable.Append("</td>");
                            }
                            else
                            {
                                Alltable.Append("<td>");
                                Alltable.Append("未开放");
                                Alltable.Append("</td>");
                            }
                        }
                        else
                        {
                            Alltable.Append("<td>");
                            Alltable.Append(dt.Rows[i][s[j]]);
                            Alltable.Append("</td>");
                        }
                    }
                }
                Alltable.Append("<td>");
                Alltable.Append("<input type='checkbox' class='check' vencode=\"" + dt.Rows[i]["Vencode"].ToString() + "\" title=\"" + dt.Rows[i]["Scode"] + "\"/>");
                Alltable.Append("</td>");
                Alltable.Append("</tr>");
            }
            Alltable.Append("</table>");
            #endregion

            #region 分页
            Alltable.Append("-----");
            Alltable.Append(PageCount + "-----" + Count);
            #endregion

            return(Alltable.ToString());
        }
Beispiel #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Checking if text boxes are empty or null
            if (Validation())
            {
                //Gettting Data FRom UI

                u.product_name   = txtproductname.Text;
                u.colour_code    = txtcolourcode.Text;
                u.supplier       = txtsupplier.Text;
                u.catagory       = txtcatagory.Text;
                u.purchase_price = txtpurchaseprice.Text;
                u.retail_price   = txtretailprice.Text;
                u.type           = txtmaxdiscount.Text;
                u.quantity       = txtquantity.Text;
                //u.added_by = 1;
                u.added_date = DateTime.Now;

                //Getting Username of the logged in user
                string   loggedUser = Login.loggedIn;
                usersbll usr        = da.GetIDFromUsername(loggedUser);

                u.added_by = usr.id;
                //Inserting Data into DAtabase
                bool check1 = dal.exist(u);
                //Checking if Product Already Exist
                if (check1 == true)
                {
                    //Showing MessageBox
                    DialogResult = MessageBox.Show("Product already exist do you want to update", "Message", MessageBoxButtons.YesNo);
                    if (DialogResult == DialogResult.Yes)
                    {
                        u.id = Convert.ToInt32(txtproductid.Text);
                        //Update Data in DataBase
                        bool check = dal.update_(u);
                        if (check == true)
                        {
                            MessageBox.Show("Record updated successfully");
                            clear();
                        }
                        else
                        {
                            MessageBox.Show("error");
                        }
                        //Refreshing Data Grid View
                        DataTable dt1 = dal.select();
                        dgvmanageproducts.DataSource = dt1;
                    }
                }
                else
                {
                    //Inserting data in DataBase
                    bool check = dal.insert(u);
                    if (check == true)
                    {
                        MessageBox.Show("Record added successfully");
                        clear();
                    }
                    else
                    {
                        MessageBox.Show("error");
                    }
                }
                //Refreshing Data Grid View
                DataTable dt = dal.select();
                dgvmanageproducts.DataSource = dt;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Checking if text boxes are empty or null
            if (Validation())
            {
                //Gettting Data FRom UI

                u.user_name = txtusername.Text;
                u.user_type = txtusertype.Text;
                u.password  = txtpassword.Text;
                u.email     = txtemail.Text;
                u.cnic      = txtcnic.Text;
                u.adress    = txtaddress.Text;
                u.phone_no  = txtphoneno.Text;
                //u.added_by = 1;
                u.added_date = DateTime.Now;

                //Getting Username of the logged in user
                string   loggedUser = Login.loggedIn;
                usersbll usr        = dal.GetIDFromUsername(loggedUser);

                u.added_by = usr.id;

                //Inserting Data into DAtabase
                bool check1 = dal.exist(u);

                //Checking if Product Already Exist
                if (check1 == true)
                {
                    //Showing MessageBox
                    DialogResult = MessageBox.Show("Product already exist do you want to update", "Message", MessageBoxButtons.YesNo);
                    if (DialogResult == DialogResult.Yes)
                    {
                        u.id = Convert.ToInt32(txtid.Text);
                        //Update Data in DataBase
                        bool check = dal.update(u);
                        if (check == true)
                        {
                            MessageBox.Show("Record updated successfully");
                            clear();
                        }
                        else
                        {
                            MessageBox.Show("error");
                        }
                        //Refreshing Data Grid View
                        DataTable dt1 = dal.select();
                        dgvusers.DataSource = dt1;
                    }
                }
                else
                {
                    //Inserting data in DataBase
                    bool check = dal.insert(u);
                    if (check == true)
                    {
                        MessageBox.Show("user data added successfully");
                        clear();
                    }
                    else
                    {
                        MessageBox.Show("error");
                    }
                }
                //Refreshing Data Grid View
                DataTable dt = dal.select();
                dgvusers.DataSource = dt;
            }
        }