예제 #1
0
        public long Insert(WBranchTransferDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "INSERT INTO tblWBranchTransfer (" +
                             "WBranchTransferNo, " +
                             "WBranchTransferDate, " +
                             "RequiredDeliveryDate, " +
                             "BranchIDFrom, " +
                             "BranchIDTo, " +
                             "TransferrerID, " +
                             "TransferrerName, " +
                             "RequestedBy, " +
                             "Status, " +
                             "Remarks" +
                             ") VALUES (" +
                             "@WBranchTransferNo, " +
                             "@WBranchTransferDate, " +
                             "@RequiredDeliveryDate, " +
                             "@BranchIDFrom, " +
                             "@BranchIDTo, " +
                             "@TransferrerID, " +
                             "@TransferrerName, " +
                             "@RequestedBy, " +
                             "@Status, " +
                             "@Remarks" +
                             ");";

                cmd.Parameters.AddWithValue("@WBranchTransferNo", Details.WBranchTransferNo);
                cmd.Parameters.AddWithValue("@WBranchTransferDate", Details.WBranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchIDFrom", Details.BranchIDFrom);
                cmd.Parameters.AddWithValue("@BranchIDTo", Details.BranchIDTo);
                cmd.Parameters.AddWithValue("@TransferrerID", Details.TransferrerID);
                cmd.Parameters.AddWithValue("@TransferrerName", Details.TransferrerName);
                cmd.Parameters.AddWithValue("@RequestedBy", Details.RequestedBy);
                cmd.Parameters.AddWithValue("@Status", Details.Status.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);

                cmd.CommandText = SQL;
                base.ExecuteNonQuery(cmd);

                return(Int64.Parse(base.getLAST_INSERT_ID(this)));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #2
0
        public void Update(WBranchTransferDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "UPDATE tblWBranchTransfer SET " +
                             "WBranchTransferNo			=	@WBranchTransferNo, "+
                             "WBranchTransferDate			=	@WBranchTransferDate, "+
                             "BranchIDFrom				=	@BranchIDFrom, "+
                             "BranchIDTo 				=	@BranchIDTo, "+
                             "TransferrerID			    =	@TransferrerID, "+
                             "TransferrerName            =   @TransferrerName, " +
                             "RequestedBy                =   @RequestedBy, " +
                             "Remarks                    =   @Remarks " +
                             "WHERE WBranchTransferID = @WBranchTransferID;";

                cmd.Parameters.AddWithValue("@WBranchTransferNo", Details.WBranchTransferNo);
                cmd.Parameters.AddWithValue("@WBranchTransferDate", Details.WBranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchIDFrom", Details.BranchIDFrom);
                cmd.Parameters.AddWithValue("@BranchIDTo", Details.BranchIDTo);
                cmd.Parameters.AddWithValue("@TransferrerID", Details.TransferrerID);
                cmd.Parameters.AddWithValue("@TransferrerName", Details.TransferrerName);
                cmd.Parameters.AddWithValue("@RequestedBy", Details.RequestedBy);
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@WBranchTransferID", Details.WBranchTransferID);

                cmd.CommandText = SQL;
                base.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #3
0
		private void SaveRecord()
		{
            WBranchTransferDetails clsDetails = new WBranchTransferDetails();

            clsDetails.WBranchTransferID = long.Parse(lblWBranchTransferID.Text);
            clsDetails.WBranchTransferNo = lblWBranchTransferNo.Text;
            clsDetails.WBranchTransferDate = Convert.ToDateTime(lblWBranchTransferDate.Text);
            clsDetails.BranchIDFrom = Convert.ToInt16(cboBranchFrom.SelectedItem.Value);
            clsDetails.BranchIDTo = Convert.ToInt16(cboBranchTo.SelectedItem.Value);
            clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text);
            clsDetails.TransferrerID = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.TransferrerName = Session["Name"].ToString();
            clsDetails.RequestedBy = txtRequestedBy.Text;
            clsDetails.Status = WBranchTransferStatus.Open;
            clsDetails.Remarks = txtRemarks.Text;

            WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
            clsWBranchTransfer.Update(clsDetails);
            clsWBranchTransfer.CommitAndDispose();
		}
예제 #4
0
		public long Insert(WBranchTransferDetails Details)
		{
			try 
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

				string SQL = "INSERT INTO tblWBranchTransfer (" +
								            "WBranchTransferNo, " +
								            "WBranchTransferDate, " +
								            "RequiredDeliveryDate, " +
								            "BranchIDFrom, " +
                                            "BranchIDTo, " +
								            "TransferrerID, " +
                                            "TransferrerName, " +
                                            "RequestedBy, " +
								            "Status, " +
								            "Remarks" +
							            ") VALUES (" +
                                            "@WBranchTransferNo, " +
                                            "@WBranchTransferDate, " +
                                            "@RequiredDeliveryDate, " +
                                            "@BranchIDFrom, " +
                                            "@BranchIDTo, " +
                                            "@TransferrerID, " +
                                            "@TransferrerName, " +
                                            "@RequestedBy, " +
                                            "@Status, " +
                                            "@Remarks" +
							            ");";
				  
                cmd.Parameters.AddWithValue("@WBranchTransferNo", Details.WBranchTransferNo);
                cmd.Parameters.AddWithValue("@WBranchTransferDate", Details.WBranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchIDFrom", Details.BranchIDFrom);
                cmd.Parameters.AddWithValue("@BranchIDTo", Details.BranchIDTo);
                cmd.Parameters.AddWithValue("@TransferrerID", Details.TransferrerID);
                cmd.Parameters.AddWithValue("@TransferrerName", Details.TransferrerName);
                cmd.Parameters.AddWithValue("@RequestedBy", Details.RequestedBy);
                cmd.Parameters.AddWithValue("@Status", Details.Status.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);

                cmd.CommandText = SQL;
				base.ExecuteNonQuery(cmd);

                return Int64.Parse(base.getLAST_INSERT_ID(this));
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
예제 #5
0
        public System.Data.DataTable ListAsDataTable(Int64 WBranchTransferID = 0, Int64 SupplierID = 0, WBranchTransferDetails SearchKey = new WBranchTransferDetails(), 
                                                    WBranchTransferStatus WBranchTransferstatus = WBranchTransferStatus.All, 
                                                    DateTime? OrderStartDate = null, DateTime? OrderEndDate = null, 
                                                    DateTime? PostingStartDate = null, DateTime? PostingEndDate = null,
                                                    DateTime? DeliveryStartDate = null, DateTime? DeliveryEndDate = null, 
                                                    string SortField = "WBranchTransferID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = SQLSelect() + "WHERE 1=1 ";

                if (WBranchTransferID != 0) SQL += "AND WBranchTransferID = @WBranchTransferID ";
                if (SupplierID != 0) SQL += "AND SupplierID = @SupplierID ";
                if (WBranchTransferstatus != WBranchTransferStatus.All) SQL += "AND Status = @Status ";
                if (OrderStartDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND WBranchTransferDate >= @OrderStartDate ";
                if (OrderEndDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND WBranchTransferDate <= @OrderEndDate ";
                if (PostingStartDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND WBranchTransferDate >= @PostingStartDate ";
                if (PostingEndDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND WBranchTransferDate <= @PostingEndDate ";
                if (DeliveryStartDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND DeliveryDate >= @DeliveryStartDate ";
                if (DeliveryEndDate.GetValueOrDefault() != DateTime.MinValue) SQL += "AND DeliveryDate <= @DeliveryEndDate ";
                
                SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "WBranchTransferID") + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                if (WBranchTransferID != 0) cmd.Parameters.AddWithValue("@WBranchTransferID", WBranchTransferID);
                if (SupplierID != 0) cmd.Parameters.AddWithValue("@SupplierID", SupplierID);
                if (WBranchTransferstatus != WBranchTransferStatus.All) cmd.Parameters.AddWithValue("@Status", WBranchTransferstatus.ToString("d"));
                if (OrderStartDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@OrderStartDate", OrderStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : OrderStartDate);
                if (OrderEndDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@OrderEndDate", OrderEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : OrderEndDate);
                if (PostingStartDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@PostingStartDate", PostingStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingStartDate);
                if (PostingEndDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@PostingEndDate", PostingEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingEndDate);
                if (DeliveryStartDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@DeliveryStartDate", DeliveryStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : DeliveryStartDate);
                if (DeliveryEndDate.GetValueOrDefault() != DateTime.MinValue) cmd.Parameters.AddWithValue("@DeliveryEndDate", DeliveryEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : DeliveryEndDate);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return dt;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }	
        }
예제 #6
0
		public WBranchTransferDetails Details(long WBranchTransferID)
		{
			try
			{
				string SQL=	SQLSelect() + "WHERE WBranchTransferID = @WBranchTransferID;";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmWBranchTransferID = new MySqlParameter("@WBranchTransferID",MySqlDbType.Int16);
				prmWBranchTransferID.Value = WBranchTransferID;
				cmd.Parameters.Add(prmWBranchTransferID);

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);
				
				WBranchTransferDetails Details = new WBranchTransferDetails();

                foreach (System.Data.DataRow dr in dt.Rows)
				{
					Details.WBranchTransferID = WBranchTransferID;
					Details.WBranchTransferNo = "" + dr["WBranchTransferNo"].ToString();
					Details.WBranchTransferDate = DateTime.Parse(dr["WBranchTransferDate"].ToString());
					Details.RequiredDeliveryDate = DateTime.Parse(dr["RequiredDeliveryDate"].ToString());
                    Details.BranchIDFrom = Int16.Parse(dr["BranchIDFrom"].ToString());
                    Details.BranchCodeFrom = "" + dr["BranchCodeFrom"].ToString();
                    Details.BranchNameFrom = "" + dr["BranchNameFrom"].ToString();
                    Details.BranchAddressFrom = "" + dr["BranchAddressFrom"].ToString();
                    Details.BranchIDTo = Int16.Parse(dr["BranchIDTo"].ToString());
                    Details.BranchCodeTo = "" + dr["BranchCodeTo"].ToString();
                    Details.BranchNameTo = "" + dr["BranchNameTo"].ToString();
                    Details.BranchAddressTo = "" + dr["BranchAddressTo"].ToString();
					Details.TransferrerID = Int64.Parse(dr["TransferrerID"].ToString());
                    Details.TransferrerName = "" + dr["TransferrerName"].ToString();
                    Details.RequestedBy = "" + dr["RequestedBy"].ToString();
					Details.SubTotal = decimal.Parse(dr["SubTotal"].ToString());
					Details.Discount = decimal.Parse(dr["Discount"].ToString());
                    Details.DiscountApplied = decimal.Parse(dr["DiscountApplied"].ToString());
                    Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), Convert.ToInt16(dr["DiscountType"]).ToString());
					Details.VAT = decimal.Parse(dr["VAT"].ToString());
					Details.VatableAmount = decimal.Parse(dr["VatableAmount"].ToString());
                    Details.EVAT = decimal.Parse(dr["EVAT"].ToString());
                    Details.EVatableAmount = decimal.Parse(dr["EVatableAmount"].ToString());
                    Details.LocalTax = decimal.Parse(dr["LocalTax"].ToString());
                    Details.Status = (WBranchTransferStatus)Enum.Parse(typeof(WBranchTransferStatus), Convert.ToInt16(dr["Status"]).ToString());
                    Details.Remarks = "" + dr["Remarks"].ToString();
                    Details.ReceivedBy = "" + dr["ReceivedBy"].ToString();
                    Details.DeliveryDate = DateTime.Parse(dr["DeliveryDate"].ToString());
                    Details.UnpaidAmount = decimal.Parse(dr["UnpaidAmount"].ToString());
                    Details.PaidAmount = decimal.Parse(dr["PaidAmount"].ToString());
                    Details.PaymentStatus = (WBranchTransferPaymentStatus)Enum.Parse(typeof(WBranchTransferPaymentStatus), Convert.ToInt16(dr["PaymentStatus"]).ToString());
                    Details.Freight = decimal.Parse(dr["Freight"].ToString());
                    Details.Deposit = decimal.Parse(dr["Deposit"].ToString());
                    Details.TotalItemDiscount = decimal.Parse(dr["TotalItemDiscount"].ToString());
				}

				return Details;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
예제 #7
0
		public void Update(WBranchTransferDetails Details)
		{
			try 
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL=	"UPDATE tblWBranchTransfer SET " +
                                "WBranchTransferNo			=	@WBranchTransferNo, " +
                                "WBranchTransferDate			=	@WBranchTransferDate, " +
                                "BranchIDFrom				=	@BranchIDFrom, " +
                                "BranchIDTo 				=	@BranchIDTo, " +
                                "TransferrerID			    =	@TransferrerID, " +
                                "TransferrerName            =   @TransferrerName, " +
                                "RequestedBy                =   @RequestedBy, " +
                                "Remarks                    =   @Remarks " +
							"WHERE WBranchTransferID = @WBranchTransferID;";

                cmd.Parameters.AddWithValue("@WBranchTransferNo", Details.WBranchTransferNo);
                cmd.Parameters.AddWithValue("@WBranchTransferDate", Details.WBranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchIDFrom", Details.BranchIDFrom);
                cmd.Parameters.AddWithValue("@BranchIDTo", Details.BranchIDTo);
                cmd.Parameters.AddWithValue("@TransferrerID", Details.TransferrerID);
                cmd.Parameters.AddWithValue("@TransferrerName", Details.TransferrerName);
                cmd.Parameters.AddWithValue("@RequestedBy", Details.RequestedBy);
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@WBranchTransferID", Details.WBranchTransferID);

				cmd.CommandText = SQL;
				base.ExecuteNonQuery(cmd);
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
예제 #8
0
		private void LoadList()
		{	
			WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
			DataClass clsDataClass = new DataClass();
			Common Common = new Common();

			string SortField = "WBranchTransferID";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}

			SortOption sortoption = SortOption.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

            DateTime dteTransferStartDate = DateTime.MinValue;
            try { if (txtTransferStartDate.Text != string.Empty) dteTransferStartDate = Convert.ToDateTime(txtTransferStartDate.Text + " " + txtTransferStartTime.Text); }
            catch { }

            DateTime dteTransferEndDate = DateTime.MinValue;
            try { if (txtTransferEndDate.Text != string.Empty) dteTransferEndDate = Convert.ToDateTime(txtTransferEndDate.Text + " " + txtTransferEndTime.Text); }
            catch { }

            DateTime dtePostingStartDate = DateTime.MinValue;
            try { if (txtPostingStartDate.Text != string.Empty) dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text); }
            catch { }

            DateTime dtePostingEndDate = DateTime.MinValue;
            try { if (txtPostingEndDate.Text != string.Empty) dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text); }
            catch { }

            WBranchTransferDetails searchKey = new WBranchTransferDetails();
            searchKey.WBranchTransferNo = txtSearch.Text;

            WBranchTransferStatus status = (WBranchTransferStatus)Enum.Parse(typeof(WBranchTransferStatus), cboStatus.SelectedItem.Value);
            PageData.DataSource = clsWBranchTransfer.ListAsDataTable(0, 0, searchKey, status, dteTransferStartDate, dteTransferEndDate, dtePostingStartDate, dtePostingEndDate, null, null, SortField, sortoption).DefaultView; 
			clsWBranchTransfer.CommitAndDispose();

			int iPageSize = Convert.ToInt16(Session["PageSize"]) ;
			
			PageData.AllowPaging = true;
			PageData.PageSize = iPageSize;
			try
			{
				PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;				
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}
			catch
			{
				PageData.CurrentPageIndex = 1;
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}			
			
			cboCurrentPage.Items.Clear();
			for (int i=0; i < PageData.PageCount;i++)
			{
				int iValue = i + 1;
				cboCurrentPage.Items.Add(new ListItem(iValue.ToString(),iValue.ToString()));
				if (PageData.CurrentPageIndex == i)
				{	cboCurrentPage.Items[i].Selected = true;}
				else
				{	cboCurrentPage.Items[i].Selected = false;}
			}
			lblDataCount.Text = " of " + " " + PageData.PageCount;
		}
예제 #9
0
        public System.Data.DataTable ListAsDataTable(Int64 WBranchTransferID = 0, Int64 SupplierID = 0, WBranchTransferDetails SearchKey = new WBranchTransferDetails(),
                                                     WBranchTransferStatus WBranchTransferstatus = WBranchTransferStatus.All,
                                                     DateTime?OrderStartDate    = null, DateTime?OrderEndDate               = null,
                                                     DateTime?PostingStartDate  = null, DateTime?PostingEndDate             = null,
                                                     DateTime?DeliveryStartDate = null, DateTime?DeliveryEndDate            = null,
                                                     string SortField           = "WBranchTransferID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = SQLSelect() + "WHERE 1=1 ";

                if (WBranchTransferID != 0)
                {
                    SQL += "AND WBranchTransferID = @WBranchTransferID ";
                }
                if (SupplierID != 0)
                {
                    SQL += "AND SupplierID = @SupplierID ";
                }
                if (WBranchTransferstatus != WBranchTransferStatus.All)
                {
                    SQL += "AND Status = @Status ";
                }
                if (OrderStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND WBranchTransferDate >= @OrderStartDate ";
                }
                if (OrderEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND WBranchTransferDate <= @OrderEndDate ";
                }
                if (PostingStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND WBranchTransferDate >= @PostingStartDate ";
                }
                if (PostingEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND WBranchTransferDate <= @PostingEndDate ";
                }
                if (DeliveryStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND DeliveryDate >= @DeliveryStartDate ";
                }
                if (DeliveryEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    SQL += "AND DeliveryDate <= @DeliveryEndDate ";
                }

                SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "WBranchTransferID") + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                if (WBranchTransferID != 0)
                {
                    cmd.Parameters.AddWithValue("@WBranchTransferID", WBranchTransferID);
                }
                if (SupplierID != 0)
                {
                    cmd.Parameters.AddWithValue("@SupplierID", SupplierID);
                }
                if (WBranchTransferstatus != WBranchTransferStatus.All)
                {
                    cmd.Parameters.AddWithValue("@Status", WBranchTransferstatus.ToString("d"));
                }
                if (OrderStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@OrderStartDate", OrderStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : OrderStartDate);
                }
                if (OrderEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@OrderEndDate", OrderEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : OrderEndDate);
                }
                if (PostingStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@PostingStartDate", PostingStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingStartDate);
                }
                if (PostingEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@PostingEndDate", PostingEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingEndDate);
                }
                if (DeliveryStartDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@DeliveryStartDate", DeliveryStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : DeliveryStartDate);
                }
                if (DeliveryEndDate.GetValueOrDefault() != DateTime.MinValue)
                {
                    cmd.Parameters.AddWithValue("@DeliveryEndDate", DeliveryEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : DeliveryEndDate);
                }

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return(dt);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #10
0
        public WBranchTransferDetails Details(long WBranchTransferID)
        {
            try
            {
                string SQL = SQLSelect() + "WHERE WBranchTransferID = @WBranchTransferID;";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmWBranchTransferID = new MySqlParameter("@WBranchTransferID", MySqlDbType.Int16);
                prmWBranchTransferID.Value = WBranchTransferID;
                cmd.Parameters.Add(prmWBranchTransferID);

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                WBranchTransferDetails Details = new WBranchTransferDetails();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.WBranchTransferID    = WBranchTransferID;
                    Details.WBranchTransferNo    = "" + dr["WBranchTransferNo"].ToString();
                    Details.WBranchTransferDate  = DateTime.Parse(dr["WBranchTransferDate"].ToString());
                    Details.RequiredDeliveryDate = DateTime.Parse(dr["RequiredDeliveryDate"].ToString());
                    Details.BranchIDFrom         = Int16.Parse(dr["BranchIDFrom"].ToString());
                    Details.BranchCodeFrom       = "" + dr["BranchCodeFrom"].ToString();
                    Details.BranchNameFrom       = "" + dr["BranchNameFrom"].ToString();
                    Details.BranchAddressFrom    = "" + dr["BranchAddressFrom"].ToString();
                    Details.BranchIDTo           = Int16.Parse(dr["BranchIDTo"].ToString());
                    Details.BranchCodeTo         = "" + dr["BranchCodeTo"].ToString();
                    Details.BranchNameTo         = "" + dr["BranchNameTo"].ToString();
                    Details.BranchAddressTo      = "" + dr["BranchAddressTo"].ToString();
                    Details.TransferrerID        = Int64.Parse(dr["TransferrerID"].ToString());
                    Details.TransferrerName      = "" + dr["TransferrerName"].ToString();
                    Details.RequestedBy          = "" + dr["RequestedBy"].ToString();
                    Details.SubTotal             = decimal.Parse(dr["SubTotal"].ToString());
                    Details.Discount             = decimal.Parse(dr["Discount"].ToString());
                    Details.DiscountApplied      = decimal.Parse(dr["DiscountApplied"].ToString());
                    Details.DiscountType         = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), Convert.ToInt16(dr["DiscountType"]).ToString());
                    Details.VAT               = decimal.Parse(dr["VAT"].ToString());
                    Details.VatableAmount     = decimal.Parse(dr["VatableAmount"].ToString());
                    Details.EVAT              = decimal.Parse(dr["EVAT"].ToString());
                    Details.EVatableAmount    = decimal.Parse(dr["EVatableAmount"].ToString());
                    Details.LocalTax          = decimal.Parse(dr["LocalTax"].ToString());
                    Details.Status            = (WBranchTransferStatus)Enum.Parse(typeof(WBranchTransferStatus), Convert.ToInt16(dr["Status"]).ToString());
                    Details.Remarks           = "" + dr["Remarks"].ToString();
                    Details.ReceivedBy        = "" + dr["ReceivedBy"].ToString();
                    Details.DeliveryDate      = DateTime.Parse(dr["DeliveryDate"].ToString());
                    Details.UnpaidAmount      = decimal.Parse(dr["UnpaidAmount"].ToString());
                    Details.PaidAmount        = decimal.Parse(dr["PaidAmount"].ToString());
                    Details.PaymentStatus     = (WBranchTransferPaymentStatus)Enum.Parse(typeof(WBranchTransferPaymentStatus), Convert.ToInt16(dr["PaymentStatus"]).ToString());
                    Details.Freight           = decimal.Parse(dr["Freight"].ToString());
                    Details.Deposit           = decimal.Parse(dr["Deposit"].ToString());
                    Details.TotalItemDiscount = decimal.Parse(dr["TotalItemDiscount"].ToString());
                }

                return(Details);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #11
0
        private void AddItemToInventory(long WBranchTransferID)
        {
            WBranchTransferDetails clsWBranchTransferDetails = Details(WBranchTransferID);
            ERPConfig        clsERPConfig        = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem(base.Connection, base.Transaction);
            ProductUnit         clsProductUnit         = new ProductUnit(base.Connection, base.Transaction);
            Products            clsProduct             = new Products(base.Connection, base.Transaction);

            Inventory        clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            System.Data.DataTable dt = clsWBranchTransferItem.ListAsDataTable(WBranchTransferID, "WBranchTransferItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID     = Int64.Parse(dr["ProductID"].ToString());
                int  intProductUnitID = Int16.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity     = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long    lngVariationMatrixID = Int64.Parse(dr["VariationMatrixID"].ToString());
                string  strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string  strProductCode       = "" + dr["ProductCode"].ToString();
                string  strProductUnitCode   = "" + dr["ProductUnitCode"].ToString();
                decimal decUnitCost          = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost          = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Subtract BranchIDFrom then Add to BranchIDTo -- Inventory
                 * ****************************************/
                clsProduct.SubtractQuantity(clsWBranchTransferDetails.BranchIDFrom, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_BRANCH_TRANSFER_FROM) + " " + clsWBranchTransferDetails.BranchCodeFrom + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);
                clsProduct.AddQuantity(clsWBranchTransferDetails.BranchIDTo, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_BRANCH_TRANSFER_TO) + " " + clsWBranchTransferDetails.BranchCodeTo + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsWBranchTransferDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo       = clsWBranchTransferDetails.WBranchTransferNo;
                clsInventoryDetails.ContactID         = Constants.C_RETAILPLUS_SUPPLIERID;
                clsInventoryDetails.ContactCode       = Constants.C_RETAILPLUS_SUPPLIER;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;

                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT  = decItemCost; // Purchase Cost with VAT

                // insert into branchid from with minus quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDFrom;
                clsInventoryDetails.PurchaseQuantity = -decQuantity;
                clsInventory.Insert(clsInventoryDetails);

                // insert into branchid to with add quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDTo;
                clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventory.Insert(clsInventoryDetails);
            }
        }
예제 #12
0
 private void UpdateFooter(WBranchTransferDetails clsWBranchTransferDetails)
 {
     lblWBranchTransferDiscount.Text = clsWBranchTransferDetails.Discount.ToString("#,##0.#0");
     lblWBranchTransferVatableAmount.Text = clsWBranchTransferDetails.VatableAmount.ToString("#,##0.#0");
     txtWBranchTransferFreight.Text = clsWBranchTransferDetails.Freight.ToString("#,##0.#0");
     txtWBranchTransferDeposit.Text = clsWBranchTransferDetails.Deposit.ToString("#,##0.#0");
     lblWBranchTransferSubTotal.Text = Convert.ToDecimal(clsWBranchTransferDetails.SubTotal - clsWBranchTransferDetails.VAT).ToString("#,##0.#0");
     lblWBranchTransferVAT.Text = clsWBranchTransferDetails.VAT.ToString("#,##0.#0");
     lblWBranchTransferTotal.Text = clsWBranchTransferDetails.SubTotal.ToString("#,##0.#0");
 }
예제 #13
0
        private void UpdateDeposit()
        {
            WBranchTransferDetails clsWBranchTransferDetails = new WBranchTransferDetails();
            clsWBranchTransferDetails.WBranchTransferID = Convert.ToInt64(lblWBranchTransferID.Text);
            clsWBranchTransferDetails.Deposit = Convert.ToDecimal(txtWBranchTransferDeposit.Text);

            WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
            clsWBranchTransfer.UpdateDeposit(clsWBranchTransferDetails.WBranchTransferID, clsWBranchTransferDetails.Deposit);
            clsWBranchTransfer.SynchronizeAmount(Convert.ToInt64(lblWBranchTransferID.Text));
            clsWBranchTransferDetails = clsWBranchTransfer.Details(Convert.ToInt64(lblWBranchTransferID.Text));
            clsWBranchTransfer.CommitAndDispose();

            UpdateFooter(clsWBranchTransferDetails);
        }
예제 #14
0
        private void UpdateWBranchTransferDiscount()
        {
            WBranchTransferDetails clsWBranchTransferDetails = new WBranchTransferDetails();
            clsWBranchTransferDetails.WBranchTransferID = Convert.ToInt64(lblWBranchTransferID.Text);
            clsWBranchTransferDetails.DiscountApplied = Convert.ToDecimal(txtWBranchTransferDiscountApplied.Text);
            clsWBranchTransferDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboWBranchTransferDiscountType.SelectedItem.Value);

            WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
            clsWBranchTransfer.UpdateDiscount(clsWBranchTransferDetails.WBranchTransferID, clsWBranchTransferDetails.DiscountApplied, clsWBranchTransferDetails.DiscountType);
            clsWBranchTransfer.SynchronizeAmount(Convert.ToInt64(lblWBranchTransferID.Text));
            clsWBranchTransferDetails = clsWBranchTransfer.Details(Convert.ToInt64(lblWBranchTransferID.Text));
            clsWBranchTransfer.CommitAndDispose();

            UpdateFooter(clsWBranchTransferDetails);
        }
예제 #15
0
		private void SaveRecord()
		{
			WBranchTransferItemDetails clsDetails = new WBranchTransferItemDetails();

			Products clsProducts = new Products();
            ProductDetails clsProductDetails = clsProducts.Details1(Constants.BRANCH_ID_MAIN, Convert.ToInt64(cboProductCode.SelectedItem.Value));
			
			Terminal clsTerminal = new Terminal(clsProducts.Connection, clsProducts.Transaction);
            TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString());
			clsProducts.CommitAndDispose();

			clsDetails.WBranchTransferID = Convert.ToInt64(lblWBranchTransferID.Text);
			clsDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value);
			clsDetails.ProductCode = clsProductDetails.ProductCode;
			clsDetails.BarCode = clsProductDetails.BarCode;
			clsDetails.Description = clsProductDetails.ProductDesc;
			clsDetails.ProductUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value);
			clsDetails.ProductUnitCode = cboProductUnit.SelectedItem.Text;
			clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
            clsDetails.UnitCost = Convert.ToDecimal(txtPrice.Text);
            clsDetails.Discount = getItemTotalDiscount();
            clsDetails.DiscountApplied = Convert.ToDecimal(txtDiscount.Text);
            if (clsDetails.DiscountApplied == 0)
            {
                if (chkInPercent.Checked == true)
                    clsDetails.DiscountType = DiscountTypes.Percentage;
                else
                    clsDetails.DiscountType = DiscountTypes.FixedValue;
            }
            else {
                clsDetails.DiscountType = DiscountTypes.NotApplicable;
            }

            clsDetails.IsVatable = chkIsTaxable.Checked;
            clsDetails.Amount = ComputeItemAmount();

            if (clsDetails.IsVatable)
            {
                clsDetails.VatableAmount = clsDetails.Amount;
                clsDetails.EVatableAmount = clsDetails.Amount;
                clsDetails.LocalTax = clsDetails.Amount;

                if (clsTerminalDetails.IsVATInclusive == false)
                {
                    if (clsDetails.VatableAmount < clsDetails.Discount) clsDetails.VatableAmount = 0;
                    if (clsDetails.EVatableAmount < clsDetails.Discount) clsDetails.EVatableAmount = 0;
                    if (clsDetails.LocalTax < clsDetails.Discount) clsDetails.LocalTax = 0;
                }
                else
                {
                    if (clsDetails.VatableAmount >= clsDetails.Discount) clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.VatableAmount = 0;
                    if (clsDetails.EVatableAmount >= clsDetails.Discount) clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.EVatableAmount = 0;
                    if (clsDetails.LocalTax >= clsDetails.Discount) clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100)); else clsDetails.LocalTax = 0;
                }

                clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100);
                clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100);
                clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100);
            }
            else
            {
                clsDetails.VAT = 0;
                clsDetails.VatableAmount = 0;
                clsDetails.EVAT = 0;
                clsDetails.EVatableAmount = 0;
                clsDetails.LocalTax = 0;
            }

            clsDetails.isVATInclusive = clsTerminalDetails.IsVATInclusive;
            clsDetails.VariationMatrixID = Convert.ToInt64(cboVariation.SelectedItem.Value);
            if (clsDetails.VariationMatrixID != 0)
                clsDetails.MatrixDescription = cboVariation.SelectedItem.Text;
            clsDetails.ProductGroup = clsProductDetails.ProductGroupCode;
            clsDetails.ProductSubGroup = clsProductDetails.ProductSubGroupCode;
            clsDetails.Remarks = txtRemarks.Text;
            
            clsDetails.SellingPrice = decimal.Parse(txtSellingPrice.Text);
            clsDetails.SellingVAT = decimal.Parse(txtVAT.Text);
            clsDetails.SellingEVAT = decimal.Parse(txtEVAT.Text);
            clsDetails.SellingLocalTax = decimal.Parse(txtLocalTax.Text);
            clsDetails.OldSellingPrice = decimal.Parse(txtOldSellingPrice.Text);

            WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem();
            if (lblWBranchTransferItemID.Text != "0")
            {
                clsDetails.WBranchTransferItemID = Convert.ToInt64(lblWBranchTransferItemID.Text);
                clsWBranchTransferItem.Update(clsDetails);
            }
            else
                clsWBranchTransferItem.Insert(clsDetails);

            WBranchTransferDetails clsWBranchTransferDetails = new WBranchTransferDetails();
            clsWBranchTransferDetails.WBranchTransferID = clsDetails.WBranchTransferID;
            clsWBranchTransferDetails.DiscountApplied = Convert.ToDecimal(txtWBranchTransferDiscountApplied.Text);
            clsWBranchTransferDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboWBranchTransferDiscountType.SelectedItem.Value);

            WBranchTransfer clsWBranchTransfer = new WBranchTransfer(clsWBranchTransferItem.Connection, clsWBranchTransferItem.Transaction);
            clsWBranchTransfer.UpdateDiscount(clsDetails.WBranchTransferID, clsWBranchTransferDetails.DiscountApplied, clsWBranchTransferDetails.DiscountType);
            
            clsWBranchTransferDetails = clsWBranchTransfer.Details(clsDetails.WBranchTransferID);
            clsWBranchTransferItem.CommitAndDispose();

            UpdateFooter(clsWBranchTransferDetails);
		}
예제 #16
0
		private Int64 SaveRecord()
		{
			WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
			clsWBranchTransfer.GetConnection();
			lblWBranchTransferNo.Text = Constants.BRANCH_TRANSFER_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsWBranchTransfer.LastTransactionNo();

			WBranchTransferDetails clsDetails = new WBranchTransferDetails();

			clsDetails.WBranchTransferNo = lblWBranchTransferNo.Text;
			clsDetails.WBranchTransferDate = Convert.ToDateTime(lblWBranchTransferDate.Text);
            clsDetails.BranchIDFrom = Convert.ToInt16(cboBranchFrom.SelectedItem.Value);
            clsDetails.BranchIDTo = Convert.ToInt16(cboBranchTo.SelectedItem.Value);
            clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text);
			clsDetails.TransferrerID = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.TransferrerName = Session["Name"].ToString();
            clsDetails.RequestedBy = txtRequestedBy.Text;
			clsDetails.Status = WBranchTransferStatus.Open;
			clsDetails.Remarks = txtRemarks.Text;
			
			Int64 id = clsWBranchTransfer.Insert(clsDetails);
			clsWBranchTransfer.CommitAndDispose();

			return id;
		}