Пример #1
0
        /// <summary>
        /// 取得一個新銷貨退回單編號
        /// </summary>
        /// <returns></returns>
        public string GetNewReturnID(string Track)
        {
            string NewID;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 ReturnID from Sales_Return");
            strSql.Append(" where ReturnID like @ReturnID ");
            strSql.Append(" order by ReturnID Desc ");
            SqlParameter[] parameters = {
					new SqlParameter("@ReturnID", SqlDbType.Char,11)};
            parameters[0].Value = Track+"%";

            RedGlovePermission.Model.Sales_Return model = new RedGlovePermission.Model.Sales_Return();
			DataSet ds=SqlServerHelper.Query(strSql.ToString(),parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                NewID = (int.Parse(ds.Tables[0].Rows[0]["ReturnID"].ToString().Substring(10, 3)) + 1001).ToString();
                NewID = Track + NewID.Substring(NewID.Length - 3);
            }
            else
            {
                NewID = Track + "001";
            }
            return NewID;
        }
Пример #2
0
        /// <summary>
        /// 取得銷貨退回單細項編號
        /// </summary>
        /// <param name="OID">銷貨退回單編號</param>
        /// <returns></returns>
        public string GetNewReturnSeq(string OID)
        {
            string NewSEQ;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 Seq from Sales_Return_DTL");
            strSql.Append(" where ReturnID = @ReturnID ");
            strSql.Append(" order by Seq Desc ");
            SqlParameter[] parameters = {
					new SqlParameter("@ReturnID", SqlDbType.Char,13)};
            parameters[0].Value = OID;

            RedGlovePermission.Model.Sales_Return model = new RedGlovePermission.Model.Sales_Return();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                NewSEQ = (int.Parse(ds.Tables[0].Rows[0]["SEQ"].ToString()) + 1).ToString();
            }
            else
            {
                NewSEQ = "1";
            } return NewSEQ;
        }
Пример #3
0
        /// <summary>
        /// 得到一筆銷貨退回單單資料
        /// </summary>
        /// <param name="ReturnID">銷貨退回單單編號</param>
        /// <returns></returns>
        public RedGlovePermission.Model.Sales_Return GetReturnModel(string ReturnID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 * from Sales_Return ");
            strSql.Append(" where ReturnID=@ReturnID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ReturnID", SqlDbType.Char,13)};
            parameters[0].Value = ReturnID;

            RedGlovePermission.Model.Sales_Return model = new RedGlovePermission.Model.Sales_Return();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                //if (ds.Tables[0].Rows[0]["MA001"].ToString() != "")
                //{
                model.ReturnID = ds.Tables[0].Rows[0]["ReturnID"].ToString();
                //}
                model.Return_Date = ds.Tables[0].Rows[0]["Return_Date"].ToString();
                model.Company = ds.Tables[0].Rows[0]["Company"].ToString();
                model.MA001 = ds.Tables[0].Rows[0]["MA001"].ToString();
                model.CaseNo = ds.Tables[0].Rows[0]["CaseNo"].ToString();
                model.Department = ds.Tables[0].Rows[0]["Department"].ToString();
                model.TaxRate = float.Parse(ds.Tables[0].Rows[0]["TaxRate"].ToString());
                model.Amount = float.Parse(ds.Tables[0].Rows[0]["Total"].ToString());
                model.Tax = float.Parse(ds.Tables[0].Rows[0]["Tax"].ToString());
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #4
0
        protected void gvChild_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow gvr = (GridViewRow)((GridView)sender).NamingContainer;
            HiddenField _hfChildSearch = (HiddenField)gvr.FindControl("_hfChildSearch");
            SqlDataSource dsChild = (SqlDataSource)gvr.FindControl("dsChild");

            if (e.CommandName == "InsertNew")
            {
                //TextBox tbSeq = (TextBox)((GridView)sender).Controls[0].Controls[0].FindControl("tbSeq");
                TextBox tbMB001 = (TextBox)((GridView)sender).Controls[0].Controls[0].FindControl("tbMB001");
                TextBox tbQty = (TextBox)((GridView)sender).Controls[0].Controls[0].FindControl("tbQty");
                TextBox tbUnitPrice = (TextBox)((GridView)sender).Controls[0].Controls[0].FindControl("tbUnitPrice");
                TextBox tbDiscount = (TextBox)((GridView)sender).Controls[0].Controls[0].FindControl("tbDiscount");
                //if (tbSeq != null)
                //    dsChild.InsertParameters["Seq"].DefaultValue = tbSeq.Text;
                RedGlovePermission.Model.Basic_Companies model = new RedGlovePermission.Model.Basic_Companies();
                model = bll.GetCCompanyModel(CompanyList.SelectedItem.ToString());
                dsChild.InsertParameters["Seq"].DefaultValue = bllReturn.GetNewReturnSeq(gvr.Cells[5].Text);
                if (tbMB001 != null)
                    dsChild.InsertParameters["MB001"].DefaultValue = tbMB001.Text;
                if (tbQty != null)
                    dsChild.InsertParameters["Qty"].DefaultValue = tbQty.Text;
                if (tbUnitPrice != null)
                    dsChild.InsertParameters["unitPrice"].DefaultValue = tbUnitPrice.Text;
                if (tbDiscount != null)
                    dsChild.InsertParameters["Discount"].DefaultValue = tbDiscount.Text;
                else
                    dsChild.InsertParameters["Discount"].DefaultValue = "1";
                dsChild.InsertParameters["ReturnId"].DefaultValue = gvr.Cells[5].Text;
                UserSession user = SessionBox.GetUserSession();
                dsChild.InsertParameters["CREATOR"].DefaultValue = user.LoginName.ToString();
                dsChild.InsertParameters["CREATE_DATE"].DefaultValue = DateTime.Now.ToString("yyyyMMdd");
                dsChild.Insert();
                //處理單頭合計及稅額
                if (bllReturn.ReturnTotal(gvr.Cells[5].Text) == 0)
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_total_false") + "');", true);
                else
                {
                    RedGlovePermission.Model.Sales_Return Returnmodel = new RedGlovePermission.Model.Sales_Return();
                    Returnmodel = bllReturn.GetReturnModel(gvr.Cells[5].Text);
                    gvr.Cells[13].Text = Returnmodel.Amount.ToString();
                    gvr.Cells[14].Text = Returnmodel.Tax.ToString();
                }
                ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_update_true") + "');", true);
                _hfChildSearch.Value = "";
                BindChildData((GridView)sender);
            }
            if (e.CommandName == "InsertCancel")
            {
                _hfChildSearch.Value = "";
                BindChildData((GridView)sender);
            }
        }
Пример #5
0
 protected void gvChild_RowUpdated(object sender, GridViewUpdatedEventArgs e)
 {
     GridViewRow gvr = (GridViewRow)((GridView)sender).NamingContainer;
     //處理單頭合計及稅額
     if (bllReturn.ReturnTotal(gvr.Cells[5].Text) == 0)
         ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_total_false") + "');", true);
     else
     {
         RedGlovePermission.Model.Sales_Return Returnmodel = new RedGlovePermission.Model.Sales_Return();
         Returnmodel = bllReturn.GetReturnModel(gvr.Cells[5].Text);
         gvr.Cells[13].Text = Returnmodel.Amount.ToString();
         gvr.Cells[14].Text = Returnmodel.Tax.ToString();
     }
     ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_update_true") + "');", true);
 }
Пример #6
0
        protected void gvChild_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow gvr = (GridViewRow)((GridView)sender).NamingContainer;
            SqlDataSource dsChild = (SqlDataSource)gvr.FindControl("dsChild");

            dsChild.DeleteParameters["ReturnID"].DefaultValue = gvr.Cells[5].Text;
            dsChild.DeleteParameters["SEQM"].DefaultValue = ((GridView)sender).Rows[e.RowIndex].Cells[1].Text;
            dsChild.Delete();
            //處理單頭合計及稅額
            if (bllReturn.ReturnTotal(gvr.Cells[5].Text) == 0)
                ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_total_false") + "');", true);
            else
            {
                RedGlovePermission.Model.Sales_Return Returnmodel = new RedGlovePermission.Model.Sales_Return();
                Returnmodel = bllReturn.GetReturnModel(gvr.Cells[5].Text);
                gvr.Cells[13].Text = Returnmodel.Amount.ToString();
                gvr.Cells[14].Text = Returnmodel.Tax.ToString();
            }
            ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "alert('" + ResourceManager.GetString("Pub_Msg_delete_true") + "');", true);
        }